Click here to Skip to main content
15,887,381 members
Home / Discussions / C#
   

C#

 
AnswerRe: how to draw a X coordinate with a series of datetime data? Pin
Alex Korchemniy10-Feb-04 7:20
Alex Korchemniy10-Feb-04 7:20 
Generalinteract 2 way Pin
Blue_Aqua10-Feb-04 3:14
Blue_Aqua10-Feb-04 3:14 
GeneralRe: interact 2 way Pin
Heath Stewart10-Feb-04 11:10
protectorHeath Stewart10-Feb-04 11:10 
GeneralRe: interact 2 way Pin
Blue_Aqua10-Feb-04 18:23
Blue_Aqua10-Feb-04 18:23 
GeneralMultyThreading in C#: Communication between threads Pin
Jasper4C#10-Feb-04 2:46
Jasper4C#10-Feb-04 2:46 
GeneralRe: MultyThreading in C#: Communication between threads Pin
Marc Clifton10-Feb-04 4:17
mvaMarc Clifton10-Feb-04 4:17 
GeneralRe: MultyThreading in C#: Communication between threads Pin
Jasper4C#10-Feb-04 12:08
Jasper4C#10-Feb-04 12:08 
GeneralRe: MultyThreading in C#: Communication between threads Pin
Marc Clifton10-Feb-04 13:38
mvaMarc Clifton10-Feb-04 13:38 
Ok, first off, you can't call ThreadStart() the way you described because you need an instance of the class or the method you're calling has to be static.

If it's static, then anything it manipulates has to be static as well, and that means anything outside of the thread can access it as well, as long as it's static. If you made all the data and methods in ClassA static, then you could simply call ClassA.SetMessage from any thread--main application thread included.

If it's not static, then you need an instance of the object to pass along to the delegate. Since you have the instance, you can also call the SetMessage method from the application thread. For example:

ClassA myClassA=new ClassA();
ThreadStart threadDelegate=new ThreadStart(myClassA.ThreadEntrancePoint);
Thread newThread=new Thread(threadDelegate);
newThread.Start();

// in my main application:
myClassA.SetMessage="foobar";
...


I hope that helps. Note that you probably would want a "lock" statement to bracket the setter.

Marc

Latest AAL Article
My blog
Join my forum!
GeneralBackground compile in C# Pin
mufoxe10-Feb-04 2:24
mufoxe10-Feb-04 2:24 
GeneralRemoting, Events, Interfaces and Assemblies Pin
CyberHawke10-Feb-04 1:35
CyberHawke10-Feb-04 1:35 
GeneralRe: Remoting, Events, Interfaces and Assemblies Pin
Marc Clifton10-Feb-04 1:45
mvaMarc Clifton10-Feb-04 1:45 
GeneralReport Designer Pin
Itanium9-Feb-04 19:56
Itanium9-Feb-04 19:56 
GeneralRe: Report Designer Pin
Marc Clifton10-Feb-04 1:47
mvaMarc Clifton10-Feb-04 1:47 
GeneralRe: Report Designer Pin
Roger Alsing10-Feb-04 2:44
Roger Alsing10-Feb-04 2:44 
GeneralRe: Report Designer Pin
Marc Clifton10-Feb-04 3:50
mvaMarc Clifton10-Feb-04 3:50 
GeneralRe: Report Designer Pin
Itanium10-Feb-04 20:22
Itanium10-Feb-04 20:22 
GeneralTranslating from Delphi to C# - problem with objects. Pin
Andres Coder9-Feb-04 17:48
Andres Coder9-Feb-04 17:48 
GeneralRe: Translating from Delphi to C# - problem with objects. Pin
John Kuhn9-Feb-04 19:16
John Kuhn9-Feb-04 19:16 
GeneralRe: Translating from Delphi to C# - problem with objects. Pin
Andres Coder10-Feb-04 2:45
Andres Coder10-Feb-04 2:45 
GeneralRe: Translating from Delphi to C# - problem with objects. Pin
John Kuhn10-Feb-04 10:45
John Kuhn10-Feb-04 10:45 
GeneralCharacter array Pin
GetOn&GetGoing9-Feb-04 17:44
GetOn&GetGoing9-Feb-04 17:44 
GeneralRe: Character array Pin
Nick Parker9-Feb-04 18:28
protectorNick Parker9-Feb-04 18:28 
GeneralRe: Character array Pin
Marc Clifton10-Feb-04 1:49
mvaMarc Clifton10-Feb-04 1:49 
GeneralConversion from string to integer Pin
GetOn&GetGoing9-Feb-04 17:00
GetOn&GetGoing9-Feb-04 17:00 
GeneralRe: Conversion from string to integer Pin
John Kuhn9-Feb-04 17:06
John Kuhn9-Feb-04 17:06 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.