Click to Rate and Give Feedback
MSDN
MSDN Library
.NET Development
.NET Framework 3.5
Timer Class
Timer Properties
 SynchronizingObject Property
Collapse All/Expand All Collapse All
This page is specific to
Microsoft Visual Studio 2008/.NET Framework 3.5

Other versions are also available for the following:
.NET Framework Class Library
Timer..::.SynchronizingObject Property

Gets or sets the object used to marshal event-handler calls that are issued when an interval has elapsed.

Namespace:  System.Timers
Assembly:  System (in System.dll)
Visual Basic (Declaration)
<BrowsableAttribute(False)> _
<TimersDescriptionAttribute("TimerSynchronizingObject")> _
Public Property SynchronizingObject As ISynchronizeInvoke
Visual Basic (Usage)
Dim instance As Timer
Dim value As ISynchronizeInvoke

value = instance.SynchronizingObject

instance.SynchronizingObject = value
C#
[BrowsableAttribute(false)]
[TimersDescriptionAttribute("TimerSynchronizingObject")]
public ISynchronizeInvoke SynchronizingObject { get; set; }
Visual C++
[BrowsableAttribute(false)]
[TimersDescriptionAttribute(L"TimerSynchronizingObject")]
public:
property ISynchronizeInvoke^ SynchronizingObject {
    ISynchronizeInvoke^ get ();
    void set (ISynchronizeInvoke^ value);
}
JScript
public function get SynchronizingObject () : ISynchronizeInvoke
public function set SynchronizingObject (value : ISynchronizeInvoke)

Property Value

Type: System.ComponentModel..::.ISynchronizeInvoke
The ISynchronizeInvoke representing the object used to marshal the event-handler calls that are issued when an interval has elapsed. The default is nullNothingnullptra null reference (Nothing in Visual Basic).

When SynchronizingObject is nullNothingnullptra null reference (Nothing in Visual Basic), the method that handles the Elapsed event is called on a thread from the system-thread pool. For more information on system-thread pools, see ThreadPool.

When the Elapsed event is handled by a visual Windows Forms component, such as a button, accessing the component through the system-thread pool might result in an exception or just might not work. Avoid this effect by setting SynchronizingObject to a Windows Forms component, which causes the method that handles the Elapsed event to be called on the same thread that the component was created on.

If the Timer is used inside Visual Studio in a Windows Forms designer, SynchronizingObject is automatically set to the control that contains the Timer. For example, if you place a Timer on a designer for Form1 (which inherits from Form), the SynchronizingObject property of Timer is set to the instance of Form1.

Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

Supported in: 3.5, 3.0, 2.0, 1.1, 1.0
Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
Processing
© 2010 Microsoft Corporation. All rights reserved. Terms of Use | Trademarks | Privacy Statement
Page view tracker