How might one do this
Update windows form TextBox.Text w/ a timer(c#). There is a threading issue here

I tried
http://blogs.msdn.com/csharpfaq/archive/2004/03/17/91685.asp

And got
System.InvalidOperationException: Cannot call Invoke or InvokeAsync on a control until the window handle has been created

Thanks!

Re: Updating Windows Form TextBox.Text w/ a Timer (c#) by Palo

Palo
Fri Apr 23 12:56:16 CDT 2004

> System.InvalidOperationException: Cannot call Invoke or InvokeAsync on a
control until the window handle has been created.

So go on and create the handle if they want it. :-)

The control's handle is needed by the 'magic' plumbing that actually
marshals the call to the control's thread. I have to make sure that the
handle is created *before* other threads try to call into the control.
Accessing the Control.Handle property creates the handle if it hasn't been
created already. Or you can call Control.CreateHandle if you have any
constituent controls...

Best regards,

Palo
---
http://dact.lamarvin.com/
AutoComplete component for WinForms applications. Easy to integrate, easier
to use!
http://www.vbinfozine.com/
An ordinary VB developer shares his own successes and failures



Re: Updating Windows Form TextBox.Text w/ a Timer (c#) by Elp

Elp
Fri Apr 23 14:20:45 CDT 2004


"Case" <anonymous@discussions.microsoft.com> wrote in message
news:67C06FB6-DE01-4CCF-8F28-552E257AA4F5@microsoft.com...
> How might one do this?
> Update windows form TextBox.Text w/ a timer(c#). There is a threading
issue here.

Use the System.Windows.Form.Timer instead of the System.Timers.Timer. The
Window Form timer has been made to do exactly what you want without any
threading issue as the delegate call is made in your UI thread instead of
being made in a new thread.



Re: Updating Windows Form TextBox.Text w/ a Timer (c#) by Stoitcho

Stoitcho
Mon Apr 26 08:52:39 CDT 2004

Hi Case,

I would suggest the same as Elp did. Using System.WindowsForms.Timer control
you won't have threading problems. However, I want to add that if you insist
using System.Timers.Timer class you can still get rid of the threading
problems setting Timer.SyncronizingObject property with reference to your
Form or control. If that property is set the Timer objects will call
Control's BeginInvoke for you and will switch the execution to the UI
thread.


--
B\rgds
Stoitcho Goutsev (100) [C# MVP]
"Case" <anonymous@discussions.microsoft.com> wrote in message
news:67C06FB6-DE01-4CCF-8F28-552E257AA4F5@microsoft.com...
> How might one do this?
> Update windows form TextBox.Text w/ a timer(c#). There is a threading
issue here.
>
> I tried:
> http://blogs.msdn.com/csharpfaq/archive/2004/03/17/91685.aspx
>
> And got:
> System.InvalidOperationException: Cannot call Invoke or InvokeAsync on a
control until the window handle has been created.
>
> Thanks!



RE: Updating Windows Form TextBox.Text w/ a Timer (c#) by anonymous

anonymous
Tue Apr 27 14:16:08 CDT 2004

Your are probably looking at the MSDN System.Windows.Forms.Timer() documentation. They have the timer even
private static void TimerEventProcessor marked as static. Remove the static keyword, access your text property and presto
-:



----- Case wrote: ----

How might one do this
Update windows form TextBox.Text w/ a timer(c#). There is a threading issue here

I tried
http://blogs.msdn.com/csharpfaq/archive/2004/03/17/91685.asp

And got
System.InvalidOperationException: Cannot call Invoke or InvokeAsync on a control until the window handle has been created

Thanks!