Here’s some code:
class myclass
{
enum STAT
{
IDLE=0;
READING,
WRITING,
PAINTING,
SKATTING
}
public STAT status = STAT.IDLE;
}
void reading()
{//code}
void writting()
{}
...
//Rest function bodies form accordingly
Button_click()
{
myclass test = new myclass();
status = STAT.READING
bgWorker.RunWorkerAsync();
while(status == STAT.READING)
{
label.text = "READING";
progressbar.value++;
}
status = STAT.WRITTING;
bgWorker.RunWorkerAsync();
while(status == STAT.WRITTING)
{
label.text = "READING";
progressbar.value++;
}
..........
}
bgWorker_doWork()
{
switch(status)
{
case STAT.READING: test.reading; break;
......
}
status = STAT.IDLE;
}
My code is similar to the above but when i click the button thw whole app crashes with no excepsions or anything. can someone please help? i cant figure out what im doing wrong.. 🙂
thank you and happy new year everyone.
Well i dont know if it helps anyone but i solved my problem using some Thread.Sleep(100) statements before starting each function inside DoWork(). It seems that the execution flow was too fast so the while(status == …) loops always evaluated to false. I just had to give each function some time to work before checking the STATE.
Thanks again