Search Results

Search found 1 results on 1 pages for 'mijatovic'.

Page 1/1 | 1 

  • System.Threading.Timer won't trigger

    - by mijatovic
    Hello guys, I am new here... I have one question, if somebody can help me. It is about timers (System.Threading.Timer). I want to break inevitable recursion: I have two columns in datarow and they are mutually dependant (price_without_VAT and price_with_VAT). Setting one of them will definitely cause StackOverflowException. So here's the idea: bool flag = true; void Reset(object state) { flag = true; } Now, wrap the method for changing value of one of the columns: { if(flag) { flag = false; System.Threading.Timer tmr = new System.Threading.Timer(new System.Threading.TimerCallback(Reset), null, 10, System.Threading.Timeout.Infinite); datarow.other_column = value; } } datarow.other_column.value line will immediately trigger the above method, but there will be no recursion because flag is false. In 10 ms flag should be back to true, and everything is back to normal. Now, when i follow the code in DEBUGGER, everything works fine, but when I start app NORMALLY Reset function simply will not trigger, flag is stuck to false forever and everything false apart. I play around with due_time parameter but nothing seems to help. Any ideas?

    Read the article

1