Concept thread

  • Thread starter Thread starter Markus Freitag
  • Start date Start date
M

Markus Freitag

Guest
Hello,

I have a small or aaybe a big problem.

Current state:

public class A
{
int SendMessage(string);
}

MainThread

private A CurrentA;

public void Step1()
{
int ret = CurrentA.SendMessage("Step1");
}

public void Step5()
{
int ret = CurrentA.SendMessage("Step5");
}


public void Step9()
{
for ( int i=0; i<100; i++ )
{
int ret = CurrentA.SendMessage("Step5" + i.ToString());
}
}


Step1 and Step5 is synchronous and waits until the function returns.

Now, should be:

Step9() I have to call and process asynchronously.

How can I solve this? It could happen that Step1 is called prematurely before Step9 is completely processed.

Do I have to call the function SendMessage for everyone in one thread?

Start the thread for each call?

Process is

Cycle (Loop)
Step1 --- Step5 ----Step9(Thread, because needs time)

Every time Step1, Step5, Step9, then Step1, Step5, Step9

Can be Step1, Step5, Step1, then Step9, that is wrong.

Thanks for your help and a good sample.

Greetings Markus

Continue reading...
 
Back
Top