CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2

Hybrid View

  1. #1
    Join Date
    Apr 2011

    WebBrowser control and timer threads

    I am building a C# application that uses the Facebook SDK to poll a person's FB feed periodically for updates. Facebook uses OAuth and I can check to see if a person is logged in upon application startup. The way it works, to log in, the application opens a form with a WebBrowser control which will open the facebook authorization page. If the person grants the app permission, an authorization key is saved. At this point I can periodically check for updates using that key. But if for some reason, the user revokes permission for the app using the FB application authorization page, my application should recognize that by catching an OAuth exception (that works). But what doesn't work is I cannot load the WebBrowser form because this is coming in on a System.Timers.Timer thread. I have found that it will work if I change my timer to a Windows.Forms.Timer, but of course that makes the GUI unresponsive while it is checking the feed for updates. I've also tried using a few different Invokes, but I never got that to work. Googling this returns many pages that suggest adding [STAThread] to the beginning of the Main() program entry, and my app does have that. Can someone show me, in pseudo code, how I can have this WebBrowser control open on System.Timers.Timer thread?

    By the way, just to be clear, I am talking about a C# desktop application here, that uses the FB SDK to read a person's FB feed.


  2. #2
    Arjay's Avatar
    Arjay is offline Moderator / MS MVP Power Poster
    Join Date
    Aug 2004

    Re: WebBrowser control and timer threads

    Use the Windows.Forms.Timer and inside the timer event perform the operation within ThreadPool.QueueUserWorkItem.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Windows Mobile Development Center

Click Here to Expand Forum to Full Width

On-Demand Webinars (sponsored)

We have made updates to our Privacy Policy to reflect the implementation of the General Data Protection Regulation.