Hi,
I'm new with programming and I have a question relating thread. Please look at the following example:
....
thread = new Thread(new ThreadStart(Ope n));
thread.Start();
....
private void Open()
{
try
{
while (true)
{
receiver = new StreamReader(cl ient.GetStream( ));
input = receiver.ReadLi ne();
......
I noticed that the thread is paused (or blocked) until "receiver" receive data. Now my question is how to replicates this behavior?
Example:
int DoSomething()
{
int result = 0;
// do something here
return result;
}
void ThreadFunction
{
while(true)
{
// process here
int b = DoSomething() <-- i want the thread to "stop" here until there is actually something to do
// process here some more
}
}
Thanks in advance.
I'm new with programming and I have a question relating thread. Please look at the following example:
....
thread = new Thread(new ThreadStart(Ope n));
thread.Start();
....
private void Open()
{
try
{
while (true)
{
receiver = new StreamReader(cl ient.GetStream( ));
input = receiver.ReadLi ne();
......
I noticed that the thread is paused (or blocked) until "receiver" receive data. Now my question is how to replicates this behavior?
Example:
int DoSomething()
{
int result = 0;
// do something here
return result;
}
void ThreadFunction
{
while(true)
{
// process here
int b = DoSomething() <-- i want the thread to "stop" here until there is actually something to do
// process here some more
}
}
Thanks in advance.
Comment