timer and threading?
-
i start my timer than when timer is elapsed i want to change my sliderbars value in private void timer1_elapsed(object sender, System.Timers.ElapsedEventArgs e) { slider1.value=100; //i get error message in this line about threading and debug s broken.how can i solve it? }
-
i start my timer than when timer is elapsed i want to change my sliderbars value in private void timer1_elapsed(object sender, System.Timers.ElapsedEventArgs e) { slider1.value=100; //i get error message in this line about threading and debug s broken.how can i solve it? }
Hi, you must be more specific: - what kind of timer, there are at least three different Timer classes in CLR - what Exception My best guess is you are NOT using a Forms.Timer hence your timer is accessing a Control from within a thread that did not create said Control, hence resulting in an InvalidOperationException. If this suits your case, read up on Control.InvokeRequired and Control.Invoke() :)
Luc Pattyn try { [Search CodeProject Articles] [Search CodeProject Forums] [Forum Guidelines] [My Articles] } catch { [Google] }
-
i start my timer than when timer is elapsed i want to change my sliderbars value in private void timer1_elapsed(object sender, System.Timers.ElapsedEventArgs e) { slider1.value=100; //i get error message in this line about threading and debug s broken.how can i solve it? }
If your timer is running in a thread that doesn't own slider then you need to call Invoke methods. Have a look at this: http://msdn.microsoft.com/msdnmag/issues/04/02/TimersinNET/
#region signature my articles #endregion
-
Hi, you must be more specific: - what kind of timer, there are at least three different Timer classes in CLR - what Exception My best guess is you are NOT using a Forms.Timer hence your timer is accessing a Control from within a thread that did not create said Control, hence resulting in an InvalidOperationException. If this suits your case, read up on Control.InvokeRequired and Control.Invoke() :)
Luc Pattyn try { [Search CodeProject Articles] [Search CodeProject Forums] [Forum Guidelines] [My Articles] } catch { [Google] }
-
If your timer is running in a thread that doesn't own slider then you need to call Invoke methods. Have a look at this: http://msdn.microsoft.com/msdnmag/issues/04/02/TimersinNET/
#region signature my articles #endregion
-
i get this message when i try to set sliderbar s value.System.InvalidOperationException.i used "using System.window.threading; " i think i must break timer s threading than slider bar s valur could be changed.
So you have confirmed my assumption. You must: either switch to a Forms.Timer or call myControl.Invoke() instead of directly trying to change the Control (read up on Invoke !). :)
Luc Pattyn try { [Search CodeProject Articles] [Search CodeProject Forums] [Forum Guidelines] [My Articles] } catch { [Google] }
-
So you have confirmed my assumption. You must: either switch to a Forms.Timer or call myControl.Invoke() instead of directly trying to change the Control (read up on Invoke !). :)
Luc Pattyn try { [Search CodeProject Articles] [Search CodeProject Forums] [Forum Guidelines] [My Articles] } catch { [Google] }
-
Hi, I'm not going to do your work. Did you try a Forms.Timer ? if not, why not ? Did you read the MSDN documentation on your current timer ? and Forms.Timer ? Did you try to call Invoke ? if so, show the code, and explain what happened. If not, why not ? Did you at least search CodeProject for InvokeRequired/Invoke ? and read an article about them ? :)
Luc Pattyn try { [Search CodeProject Articles] [Search CodeProject Forums] [Forum Guidelines] [My Articles] } catch { [Google] }
-
Hi, I'm not going to do your work. Did you try a Forms.Timer ? if not, why not ? Did you read the MSDN documentation on your current timer ? and Forms.Timer ? Did you try to call Invoke ? if so, show the code, and explain what happened. If not, why not ? Did you at least search CodeProject for InvokeRequired/Invoke ? and read an article about them ? :)
Luc Pattyn try { [Search CodeProject Articles] [Search CodeProject Forums] [Forum Guidelines] [My Articles] } catch { [Google] }