how to post message to other thread in vs.net ?

  • Thread starter Thread starter Daylor
  • Start date Start date
D

Daylor

how , can i post message to other thread in net ?
is there somthing with net that i can do ?
or i need 2 use win32 api's ?
 
Maybe I did something wrong here. But with following
code, the message is not posted.

public delegate void TestEvtHdr();
public event TestEvtHdr TestEvt;
....
this.TestEvt += new TestEvtHdr(Form1_TestEvt);
....
private void button1_Click()
{
TestEvt();
int j = 0;
for(int i = 1; i < 100; i++)
{
if ((j % 4) != 0)
{
j += i;
}
}
}
private void Form1_TestEvt()
{
int i = 1;
}

That is, by clicking on the button, the callstack become:
 
You did nothing wrong, an event is not asynchronous.
What you want and what I've beeing trying to do myself is
to send the data to the thread from the main thread and
let both continue there work. With Win32 you just need to
use PostThreadMessage, what would be the equivalent
implementation on .NET? I was thinking of maybe using a
Win32 event object but that would not be the same. If
somebody can help please let us know.

Bob
 
Back
Top