Ahhh.  Very true.  I have done this in a Winforms environment and it will allow the Timer thread to attach to the same thread the Winform is using.  I guess you can't do that with a Gtk window.  That might be something to specifically ask the Mono team.

Does anyone from the Mono team know why the below will not work?

Thanks!

Antonio

>From: Jimmy Do <[EMAIL PROTECTED]>
>Reply-To: Jimmy Do <[EMAIL PROTECTED]>
>To: Antonio Santana <[EMAIL PROTECTED]>
>Subject: Re: [Mono-list] Label stops updating during System.Timers.Timer callbacks
>Date: Tue, 21 Sep 2004 16:20:45 -0700
>
>Hmm....
>
>timer.SynchronizingObject = this;
>gives a compile-time error:
>"Cannot convert implicitly from `TimerWindow' to
>`System.ComponentModel.ISynchronizeInvoke'(CS0029)"
>
>'this' refers to a Gtk.Window, so maybe that's why it doesn't work?
>
>
>Jimmy
>
>
>----- Original Message -----
>From: Antonio Santana <[EMAIL PROTECTED]>
>Date: Tue, 21 Sep 2004 14:19:10 -0500
>Subject: RE: [Mono-list] Label stops updating during
>System.Timers.Timer callbacks
>To: [EMAIL PROTECTED], [EMAIL PROTECTED]
>
>
>You might try the following:
>
> > myCounter = 0;
> >
> > Timer timer = new Timer();
> > timer.Interval = 500;
> > timer.Elapsed += new ElapsedEventHandler(OnTimeElapsed);
>//This sets the SynchronizingObject property to
>//   synchronize with the current window or form object
>//Setting the below property should force the Timer to use the same
>thread as the UI
>//   so they don't get out of synch; otherwise, it would use it's own
>worker thread.
>timer.SynchronizingObject = this;
>
> > timer.Start();
>
>Another thing you might try doing in addition to the above:
>
> > private void OnTimeElapsed(object o, ElapsedEventArgs args)
> > {
>
>
> > myCounter++; REMOVE THIS LINE
>
> > myCountLabel.Text = Convert.ToString(Convert.ToInt32(myCounter.Text)+1));
>
>//This would merely be so you are not storing the value in the label
>object as well as the myCounter variable
> >
> > Console.WriteLine(myCounter.ToString());
>
>
> > }
>
>I hope this helps.  Let me know if this doens't improve anything.
>
>Thanks!
>
>
>
>Antonio
_______________________________________________ Mono-list maillist - [EMAIL PROTECTED] http://lists.ximian.com/mailman/listinfo/mono-list

Reply via email to