Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 957985
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T00:47:35+00:00 2026-05-16T00:47:35+00:00

Where do i get the ISynchronizeInvoke so i can sync against UI thread? System.Timers.Timer

  • 0

Where do i get the ISynchronizeInvoke so i can sync against UI thread?

System.Timers.Timer gTimer;
gTimer.SynchronizingObject;

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T00:47:36+00:00Added an answer on May 16, 2026 at 12:47 am

    This may work,

    gTimer.SynchronizingObject = new
    DispatcherWinFormsCompatAdapter(this.Dispatcher));

    internal class DispatcherWinFormsCompatAdapter : ISynchronizeInvoke
      {
           #region IAsyncResult implementation
          private class DispatcherAsyncResultAdapter : IAsyncResult
            {
                private DispatcherOperation m_op;
                 private object m_state;
    
                public DispatcherAsyncResultAdapter(DispatcherOperation operation)
                {
                    m_op = operation;
                }
    
                public DispatcherAsyncResultAdapter(DispatcherOperation operation, object state)
                   : this(operation)
                {
                    m_state = state;
               }
    
                public DispatcherOperation Operation
                {
                    get { return m_op; }
                }
    
                #region IAsyncResult Members
    
                public object AsyncState
                {
                    get { return m_state; }
                }
    
               public WaitHandle AsyncWaitHandle
                {
                    get { return null; }
                }
    
                public bool CompletedSynchronously
                {
                    get { return false; }
                }
    
                public bool IsCompleted
                {
                    get { return m_op.Status == DispatcherOperationStatus.Completed; }
                }
    
                #endregion
            }
            #endregion
            private Dispatcher m_disp;
            public DispatcherWinFormsCompatAdapter(Dispatcher dispatcher)
            {
                m_disp = dispatcher;
            }
            #region ISynchronizeInvoke Members
    
            public IAsyncResult BeginInvoke(Delegate method, object[] args)
            {
                if (args != null && args.Length > 1)
                {
                    object[] argsSansFirst = GetArgsAfterFirst(args);
                    DispatcherOperation op = m_disp.BeginInvoke(DispatcherPriority.Normal, method, args[0], argsSansFirst);
                    return new DispatcherAsyncResultAdapter(op);
                }
                else
                {
                    if (args != null)
                    {
                        return new DispatcherAsyncResultAdapter(m_disp.BeginInvoke(DispatcherPriority.Normal, method, args[0]));
                    }
                    else
                    {
                        return new DispatcherAsyncResultAdapter(m_disp.BeginInvoke(DispatcherPriority.Normal, method));
                    }
                }
            }
    
            private static object[] GetArgsAfterFirst(object[] args)
            {
                object[] result = new object[args.Length - 1];
                Array.Copy(args, 1, result, 0, args.Length - 1);
                return result;
            }
    
            public object EndInvoke(IAsyncResult result)
            {
                DispatcherAsyncResultAdapter res = result as DispatcherAsyncResultAdapter;
                if (res == null)
                    throw new InvalidCastException();
    
                while (res.Operation.Status != DispatcherOperationStatus.Completed || res.Operation.Status == DispatcherOperationStatus.Aborted)
                {
                    Thread.Sleep(50);
                }
    
                return res.Operation.Result;
            }
    
            public object Invoke(Delegate method, object[] args)
           {
               if (args != null && args.Length > 1)
               {
                   object[] argsSansFirst = GetArgsAfterFirst(args);
                   return m_disp.Invoke(DispatcherPriority.Normal, method, args[0], argsSansFirst);
               }
               else
               {
                   if (args != null)
                   {
                       return m_disp.Invoke(DispatcherPriority.Normal, method, args[0]);
                   }
                   else
                   {
                       return m_disp.Invoke(DispatcherPriority.Normal, method);
                   }
               }
           }
    
           public bool InvokeRequired
           {
               get { return m_disp.Thread != Thread.CurrentThread; }
           }
    
           #endregion
       }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I get this error while accessing a php script: W/System.err: Error reading from ./org/apache/harmony/awt/www/content/text/html.class
I get this exception: Exception in thread main java.lang.ArrayIndexOutOfBoundsException: 100 at Vindu.<init>(setevelger.java:64) at setevelger.main(setevelger.java:22)
.get() converts a jQuery object to a DOM element that Javascript can use without
GET_COOKIE('CURRENT_IM') will return a number saved in the CURRENT_IM cookie. How can I get
Get an error that the activity vTestSession can not be started and may be
Get class from div inside an li and add to the same li. The
//Get width and resize another element $(document).ready(function() { function ResizeSearch(GridID, SearchID) { var eleWidth
get an array of bluetooth ID's Broadcast the bluetooth signal manually
GET is a convenient method to post the form id, post the website id
//get the lat and loni throgh the loaddata function.java.util.ConcurrentModificationException at java.util.AbstractList$SimpleListIterator.next(AbstractList.java:64) How to resolve

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.