|
And may I know, what has this got to do with .NET?!
|
|
|
|
|
Actually I think you can't. I know that there are some possibilities, but not determining it just from the IP address, if you ask me.
Please correct me if I am wrong, would be interesting to know.
Cheers
You have the thought that modern physics just relay on assumptions, that somehow depends on a smile of a cat, which isn’t there.( Albert Einstein)
|
|
|
|
|
There is a ICMP Node Information Query request that can be issued, but I am not sure what information it returns - I've never used it. Google is (hopefully) your friend here!
No trees were harmed in the sending of this message; however, a significant number of electrons were slightly inconvenienced.
This message is made of fully recyclable Zeros and Ones
|
|
|
|
|
Dear All,
That's strange that when I use TryEnter in Timer event which triggers every 1 sec, the TryEnter() always returns true. Why there is such an error?
public partial class Form1 : Form
{
private object BlockingObj = new object();
private void timer1_Tick(object sender, EventArgs e)
{
bool ret = System.Threading.Monitor.TryEnter(BlockingObj, 1);
if (ret){
try
{
DialogResult result = MessageBox.Show("test", "", MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
}
finally
{
System.Threading.Monitor.Exit(BlockingObj);
}
}
}
}
|
|
|
|
|
geossl wrote: the TryEnter() always returns true. Why there is such an error?
Which means it is able to get a lock on the supplied object. You are releasing that lock in finally block as well. So next time when timer ticks, object will be available for locking again. I think TryEnter is behaving as expected.
|
|
|
|
|
There are a couple of things here:
1) Please try to use the "code block" button below to enclose your samples - it preserves the formatting and make it easier to read.
public partial class Form1 : Form
{
private object BlockingObj = new object();
private void timer1_Tick(object sender, EventArgs e)
{
bool ret = System.Threading.Monitor.TryEnter(BlockingObj, 1);
if (ret)
{
try
{
DialogResult result = MessageBox.Show("test", "", MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
}
finally
{
System.Threading.Monitor.Exit(BlockingObj);
}
}
}
}
2) The code: TryEnter attempts to establish an exclusive lock on the object. If it suceeds, then you display a messagebox (which is application modal, so the App can do nothing else until it is dismissed) then release the lock.
Comments:
A) because you release the lock in the timer event in which you establish it, it will always succeed.
B) Why keep the result of a MessageBox if you are going to ignore it?
C) Under what circumstances do you expect MessageBox to throw an exception? By all means put the try...catch around the exclusive lock, that will catch null objects, but otherwise it just complicates your code unneccessarily.
No trees were harmed in the sending of this message; however, a significant number of electrons were slightly inconvenienced.
This message is made of fully recyclable Zeros and Ones
|
|
|
|
|
TryEnter always succeeds because you are always calling it on the same ( UI ) thread and Monitor is reentrant.
Your MessageBox doesn't totally block the UI thread. It runs a partial message loop and one of the messages it processes is the Windows.Forms.Timer message. Therefore, when the next tick happens, your handler is run again from inside the MessageBox message loop. TryEnter succeeds because the UI thread already owns the lock and Monitor allows a thread to lock an object multiple times.
Nick
----------------------------------
Be excellent to each other
|
|
|
|
|
Dear,
I've downloaded "OutlookBar v2 2005" vb.net project from CodeProject. But I want to convert from vb.net project to C #.
Where can I find the program to convert or Visual Studio .Net has a build-in option to do that?
Many thanks,
Chuon Visoth
Angkor Wat - Cambodia
asp.net - c sharp beginner
|
|
|
|
|
.NET has no option to do this and you can find anny number of online converter tools. All you have to do is Google for "vb.net c# code converter".
|
|
|
|
|
Thanks for help!
Chuon Visoth
Angkor Wat - Cambodia
asp.net - c sharp beginner
|
|
|
|
|
Is there any way without selecting to change the format of the text? I mean, if I can set the format in the time of constructing the text?
richTextBox1.Text = (this bold)blah blah (this italic)blah
Like using html, is it possible?
Or do I have to select and change for each thing?
|
|
|
|
|
You have to select and change for each string. Unless you know RTF formatting codes like the back of your hand. It's not like HTML...
|
|
|
|
|
hey im new here
basically im using c# i need to write to a varible then out put it from diffrent classes
[code]
public class profile
{
public string postcode;
public void profileupdate()
{
Console.WriteLine("please enter postcode");
postcode = Console.ReadLine();
}
}
[/code]
im trying to inherit in this class
[code]
public class print
{
public void printseat()
{
profile profileupdate = new profile();
Console.WriteLine("" + profileupdate.postcode + "");
System.Threading.Thread.Sleep(1000000);
}
}
[/code]
i have a feeling it is because im inheriting a new instance of the varible but im not sure how to overcome it?
|
|
|
|
|
Hi,
when calling printseat on an instance of your print class, you create a new instance of profile; and you store it in a variable named profileupdate however that is completely unrelated to the profileupdate() method.
So probably the profileupdate() method never gets called at all (it is not called by the code shown), hence the postcode shown on the Console will be zero, its initial value.
BTW:
1. rather than waiting 15 minutes before your app ends, it makes sense to perform Console.ReadLine() ; that will have your app wait until you hit the ENTER key.
2. I strongly suggest you choose better names for all variables, methods, properties, etc; a careful choice for each of them makes your code much more readable and will allow you (and others) to more easily see what is going on, and to locate bugs if any.
3. please use PRE tags (e.g. by clicking the "code block" button under the textbox) to show code in a nice non-proportional font while preserving formatting.
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
ah yes the waiting is just some thing i added to stop it from closing so i could read it ect it will be changed in time.
im not sure how u mean by calling the profile update method?
profile profileupdate = new profile(); // calls the class profile stores it as a varible called profileupdate
Console.WriteLine("" + profileupdate.postcode + ""); // this calls the class stored in profile update and picks up the postcode varible?
im quite green with c# as you can probably tell
|
|
|
|
|
yes, however you also have this method
public void profileupdate()
{
Console.WriteLine("please enter postcode");
postcode = Console.ReadLine();
}
which never gets called, so postcode will have its initial value of zero.
if you never call it, what is its purpose?
and if you never set postcode to something other than zero, what is its purpose?
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
im inputing my postcode to a varible then calling it in a print class
like a ticket system using inheritance part of a uni project
|
|
|
|
|
Perhaps you meant for the profileupdate method to be a constructor?
Change public void profileupdate() to public void profile() and see what happens.
It has nothing to do with inheritence.
|
|
|
|
|
PIEBALDconsult wrote: public void profile()
too much void.
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
But void is nothing, right? I need to get some sleep.
|
|
|
|
|
tried it
im just taking the input im saving to a varible and output it within another class. so i have one class where i ask for the postcode and then when i exit back to the menu i can choose to look in the print class and see what i had inputted
Error 1 'profile': member names cannot be the same as their enclosing type C:\Documents and Settings\Administrator\Desktop\OOPD\OOPD\profile.cs 13 21 OOPD
|
|
|
|
|
|
Ah, so you're instantiating a profile , setting its value, instantiating another one, and expecting it to have the value you put in the first one? It doesn't really work that way.
|
|
|
|
|
oh right thats not good, could you give an example of how i would correct this
|
|
|
|
|
I have a standard class structure for servicing a table, one of the methods is GetRecord (does the obvious, gets the record from the database and populates the fields in the class).
When I inherit the table up the FK tree I get a warning that this method hides an underlying method
hides inherited member 'LimitMgr.clsLimitSet.LimitSetID'. Use the new keyword if hiding was intended
The questions.
1 How essential is it to implement the new keyword in this scenario?
2 Is the app exposed to error or processing faults if the new keyword is not implemented?
3 If I implement the new keyword on all methods, is there an issue when they do NOT hide an inherited method?
I am a great beleiver in elegant and correct code and I dislike having warnings scattered throughout the app, but implementing the new keyword will be a pain so I am trying to asses the impact of not doing the work
Never underestimate the power of human stupidity
RAH
|
|
|
|