Invalid cross-thread access exception

6 posts, 0 answers
  1. Wim
    Wim avatar
    8 posts
    Member since:
    Aug 2012

    Posted 01 Aug 2012 Link to this post

    Hi,

    When my application is throwing an exception, the messagebox doesn't show. Instead I get this :

    Invalid cross-thread access.

    at MS.Internal.XcpImports.CheckThread()
       at System.Windows.Application.remove_UnhandledException(EventHandler`1 value)
       at Telerik.Windows.Controls.RadDiagnostics.f(Object A_0, ApplicationUnhandledExceptionEventArgs A_1)
       at MS.Internal.Error.CallApplicationUEHandler(Exception e)
       at MS.Internal.JoltHelper.OnUnhandledException(Object sender, UnhandledExceptionEventArgs args)

    Notice the Windows.controls.RadDiagnostics entry in the stacktrace.

    I do run several methods in my Service Classes async and in a new thread.
    If I need to update the GUI i use this block of code to avoid the cross-thread exception :

    Deployment.Current.Dispatcher.BeginInvoke(() =>
    {
        //Do GUI stuff here
    });


    PS : I have no custom implementation for the messagebox.
  2. Wim
    Wim avatar
    8 posts
    Member since:
    Aug 2012

    Posted 01 Aug 2012 Link to this post

    Here is a bit more info :

    I have a Settings.XAML page, and a the bottom i have a application bar with several buttons.
    I have added a new button with the following implementation :

    private void ApplicationBarIconButton_Click(object sender, EventArgs e)
            {
                ThreadPool.QueueUserWorkItem((state) =>
                {
                    throw new Exception("Test");
                });
                 
            }

    This will throw the invalid cross-thread exception.
    If i change the event implementation to this, the exception is not thrown and the RadDiagnostics messagebox is shown :

    private void ApplicationBarIconButton_Click(object sender, EventArgs e)
    {
        throw new Exception("Test");
    }
  3. DevCraft banner
  4. Victor
    Admin
    Victor avatar
    1351 posts

    Posted 02 Aug 2012 Link to this post

    Hello Wim,

    Thanks for writing and for the info.
    We managed to reproduce the cross-thread exception. We will investigate the issue and will fix it if possible.
    Please write again if you have more feedback to share, it's greatly appreciated.

    Regards,
    Victor
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

  5. Omar
    Omar avatar
    1 posts
    Member since:
    Aug 2012

    Posted 13 Aug 2012 Link to this post

    I have some error....  :-(
  6. Wim
    Wim avatar
    8 posts
    Member since:
    Aug 2012

    Posted 20 Sep 2012 Link to this post

    Any updates on the issue ?
  7. Victor
    Admin
    Victor avatar
    1351 posts

    Posted 21 Sep 2012 Link to this post

    Hello Wim,

    Thanks for the question. The issue is fixed.
    Please download the latest internal build from your Telerik account.

    Greetings,
    Victor
    the Telerik team

    Time to cast your vote for Telerik! Tell DevPro Connections and Windows IT Pro why Telerik is your choice. Telerik is nominated in a total of 25 categories.

Back to Top
DevCraft banner