3 Replies - 875 Views - Last Post: 14 November 2012 - 09:19 AM Rate Topic: -----

#1 fronesis  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 10-November 12

Timer in WPF: problem with synchronization

Posted 10 November 2012 - 06:43 AM

Hi,

I create a WPFapp with timer and I have a trouble with SynchronizingObject property.

here a part of my code:

Private Sub Window_Loaded(sender As System.Object, e As System.Windows.RoutedEventArgs) Handles MyBase.Loaded
        tim.SynchronizingObject = Me
        tim.Interval = 1000
        tim.AutoReset = True

        AddHandler tim.Elapsed, AddressOf OnTimedEvent

    End Sub



when app is starting I recive message of error "Cannot converted object type "WpfApplication1.MainWindow" to type "System.ComponentModel.ISynchronizeInvoke" in line tim.SynchronizingObject = Me

What can I do with this error?
Many Thanks

Is This A Good Question/Topic? 0
  • +

Replies To: Timer in WPF: problem with synchronization

#2 marty617  Icon User is offline

  • New D.I.C Head

Reputation: 7
  • View blog
  • Posts: 33
  • Joined: 14-October 12

Re: Timer in WPF: problem with synchronization

Posted 10 November 2012 - 07:04 AM

The object you use to set SynchronizingObject must implement the interface ISynchronizeInvoke.

http://msdn.microsof...nizeinvoke.aspx
Was This Post Helpful? 0
  • +
  • -

#3 _HAWK_  Icon User is offline

  • Master(Of Foo)
  • member icon

Reputation: 1030
  • View blog
  • Posts: 4,012
  • Joined: 02-July 08

Re: Timer in WPF: problem with synchronization

Posted 10 November 2012 - 08:53 AM

In wpf we use the window.Dispatcher.BeginInvoke({delegate}, {object}) to pass info from other threads.

WPF Delegates
Was This Post Helpful? 0
  • +
  • -

#4 fronesis  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 10-November 12

Re: Timer in WPF: problem with synchronization

Posted 14 November 2012 - 09:19 AM

View Post_HAWK_, on 10 November 2012 - 08:53 AM, said:

In wpf we use the window.Dispatcher.BeginInvoke({delegate}, {object}) to pass info from other threads.

WPF Delegates



Thanks. Ok. I love DispatcherTimer :)
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1