|
|
How to pass arguments to a thread?
Rickard Andersson@Suza Computing
C# and C++ programmer from SWEDEN!
UIN: 50302279
E-Mail: nikado@pc.nu
Speciality: I love C#, ASP.NET and C++!
|
|
|
|
|
Rickard,
Do you mean before you start it or after its running?
|
|
|
|
|
I have seen James post now, but thank you for your time!
Rickard Andersson@Suza Computing
C# and C++ programmer from SWEDEN!
UIN: 50302279
E-Mail: nikado@pc.nu
Speciality: I love C#, ASP.NET and C++!
|
|
|
|
|
It depends on how you create your thread.
The "easy" way is to create a delegate matching the method signature and call the delegate with BeginInvoke. This will cause the delegates method to run in a thread pool thread and you get to pass your parameters in. This is a 'fire and forget' method though; so you don't get access to the underlying Thread object in your main code.
The "hard" way is to create a class specifically for the thread, with the parameters passed in to the constructor or set as properties. The thread's run method is then made public so that it can be started via the ThreadStart delegate. This method gives you far more control over the thread itself; including being able to work on the underlying Thread object.
Remember above all else, if you are modifying the GUI in someway from any thread you absolutely must use the GUI object's Invoke or BeginInvoke/EndInvoke methods to do anything to the GUI object itself. Not doing so is baaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaad mojo and will eventually break. All GUI object's expose an InvokeRequired property which tells you whether or not you have to call Invoke or BeginInvoke/EndInvoke. Look in the articles I've done for a sample of doing this.
James
"And we are all men; apart from the females." - Colin Davies
|
|
|
|
|
James T. Johnson wrote:
The "hard" way is to create a class specifically for the thread, with the parameters passed in to the constructor or set as properties. The thread's run method is then made public so that it can be started via the ThreadStart delegate. This method gives you far more control over the thread itself; including being able to work on the underlying Thread object.
Aah!
This sounds very cool!
You don'y know an article somehere on this topic?
I will check CP now...
Thank you!
Rickard Andersson@Suza Computing
C# and C++ programmer from SWEDEN!
UIN: 50302279
E-Mail: nikado@pc.nu
Speciality: I love C#, ASP.NET and C++!
|
|
|
|
|
|
Wow Nish!
Thank you! It really helpt me!!
Are you doing everything in MC++ when programming for the .NET platform!?
Rickard Andersson@Suza Computing
C# and C++ programmer from SWEDEN!
UIN: 50302279
E-Mail: nikado@pc.nu
Speciality: I love C#, ASP.NET and C++!
|
|
|
|
|
I need to draw a rectangle to the screen and then be able to remove it. I would like to have it filled with white but FillReversibleRectangle doesn't seem to allow it (at least not over the standard gray form background). Is there a way around this problem?
Thanks
|
|
|
|
|
You cannot control the color of the rectangle that is drawn, because it uses a method of drawing called XOR (output = src ^ dest [for each bit]).
This does two things: It ensures that whatever is drawn can be undrawn by drawing it again, and it is generally a very efficient way of ensuring that the rectangle is visible on the background.
The effect is that the rectangle drawn is an inverse of what was there before.
James
"And we are all men; apart from the females." - Colin Davies
|
|
|
|
|
Hey James,
Thanks, I was hoping for a different answer. So I guess that means I can't use FillReversibleRectangle.
-------------
|
|
|
|
|
1. I have a string containing a number. Any way to convert that number to an intregfer value (without manually converzing to a char array and checking letters, thus code an own function for that)
2. If i receive a message with UdpClient how to look up the ip?
|
|
|
|
|
1)
string x = "6";
int y;
y = Convert.ToInt32(x);
|
|
|
|
|
can any bode tell if user generate or produce any message on a button how to get information about that message?
r00d0034@yahoo.com
|
|
|
|
|
Do you mean you would like to know when a button has been clicked?
If that's the case then you need to create an event handler. If you are using VS.NET simply double click the button that you've placed on the form in the form designer and enter your code into the method that the IDE creates for you.
If you're not using VS.NET then you might want to look at this article in MSDN (as weel as the "See Also" articles)
http://msdn.microsoft.com/library/en-us/cpguide/html/cpconeventsdelegates.asp
(You might want to look at that article even if you are using VS.NET)
|
|
|
|
|
Does anyone know what messages are sent to a RichTextBox when a new line is created? - i.e. when the enter and delete buttons are pressed?
Email: theeclypse@hotmail.com URL: http://www.onyeyiri.co.uk "All programmers are playwrights and all computers are lousy actors."
|
|
|
|
|
Hi
Cant you just get that on the keypress event?
Look at Spy++, oops forgot you dont have VS
Does anyone know of a freeware version of Spy++?
MYrc : A .NET IRC client with C# Plugin Capabilities. See
http://sourceforge.net/projects/myrc for more info.
|
|
|
|
|
leppie wrote:
Does anyone know of a freeware version of Spy++?
Is Spy++ not free?
Rickard Andersson@Suza Computing
C# and C++ programmer from SWEDEN!
UIN: 50302279
E-Mail: nikado@pc.nu
Speciality: I love C#, ASP.NET and C++!
|
|
|
|
|
I assume so
In the about box it has text about no unauthorised reproduction or distribution.
MYrc : A .NET IRC client with C# Plugin Capabilities. See
http://sourceforge.net/projects/myrc for more info.
|
|
|
|
|
|
|
|
Had a look at it, quite nice esp the way u can just apply messages on the fly, but ir doesnt seem to show incoming messages like spy++, will look some more for something that can do that.
MYrc : A .NET IRC client with C# Plugin Capabilities. See
http://sourceforge.net/projects/myrc for more info.
|
|
|
|
|
hey hey, i need to catch another event - when the person moves the scrollbar, and i dont mean pressing the buttons.
Email: theeclypse@hotmail.com URL: http://www.onyeyiri.co.uk "All programmers are playwrights and all computers are lousy actors."
|
|
|
|
|
I'm Zafer
I have started to learn C# Lrogramming Language. But I have some problems about this language.
Firstly,
I wrote some programs.But I don't know, install application. For instance, when i write program in VBasic,
i convert it to setup program. But now I did not solve this problem.How can I solve this problem? Because
I need to install another computers.
Secondly,
In VBasic, I am using movenext,movefirst, movelast (etc..) commands for reading DataBase file.
If you know, ADO.NET has these commands, or similer commands?
Thirdly,
Some other my programs, I need to use Barcod reader, Printer and plotter. Furthermore,
I need to use parallel or serial ports. Other wise how can I take information from wireless cameras.
How can I use these devices in C#.Net.
If you help me about thise problems, I will so happy.
If you can't help me, who can help me please say me.
Thank you so much.
|
|
|
|