I have a program like this:
Class a
{
main()
{
while(abc)
{
f(a);
g(b);
}
}
}
but I need to check stdin for some important command. The programm should work will I receive a command from stdin. and after the command I should decide to continue execution or doing something else. What should I do?
Execute f and g in different threads with some sort of variable accessed by both to propagate the state change.
Class Program
{
public static void Main()
{
ThreadPool.QueueUserWorkItem(() => f(a));
ThreadPool.QueueUserWorkItem(() => g(b));
while(true)
{
if(Console.Readline() == "something")
//do something
}
}
private static void f (param)
{
while(abc)
//do work
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With