Calling Event (sending Datatable) in Timer event problem!

  • Thread starter Thread starter Anders
  • Start date Start date
A

Anders

Hi all,

I have two classes: Form1 and GrabTitle

Form1 instantiates GrabTitle

In GrabTitle there is a Timer event which calls several events in Form1. The
strange thing is that one event works while another doesnt.

The event transfering a text string works while another transfering a
DataTable do not! If I run the Timer event manually then it everything
works.

Any idea are much appreciated. I havent been able to find any similar issues
online (google)

Anders
 
Anders,

What kind of timer are you using? If you are using a Timer from the
System.Timers namespace, then the timer callback will come back on a thread
most likely different from the UI thread, and you will have to marshal the
call back to the UI thread (through a call to the Invoke method on the
control).

Hope this helps.
 
Thanks Nicholas, this put me in the right direction. I have found a very
descriptive article about the subject:
http://weblogs.asp.net/justin_rogers/articles/126345.aspx

Now I should be able to fix it once I understand the logic.

cheers,
Anders

Nicholas Paldino said:
Anders,

What kind of timer are you using? If you are using a Timer from the
System.Timers namespace, then the timer callback will come back on a
thread most likely different from the UI thread, and you will have to
marshal the call back to the UI thread (through a call to the Invoke
method on the control).

Hope this helps.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

Anders said:
Hi all,

I have two classes: Form1 and GrabTitle

Form1 instantiates GrabTitle

In GrabTitle there is a Timer event which calls several events in Form1.
The strange thing is that one event works while another doesnt.

The event transfering a text string works while another transfering a
DataTable do not! If I run the Timer event manually then it everything
works.

Any idea are much appreciated. I havent been able to find any similar
issues online (google)

Anders
 
Back
Top