This is a migrated thread and some comments may be shown as answers.

Invalid cross-thread access exception

5 Answers 119 Views
Diagnostics
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Wim
Top achievements
Rank 1
Wim asked on 01 Aug 2012, 01:14 PM
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.

5 Answers, 1 is accepted

Sort by
0
Wim
Top achievements
Rank 1
answered on 01 Aug 2012, 01:29 PM
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");
}
0
Victor
Telerik team
answered on 02 Aug 2012, 03:14 PM
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.

0
Omar
Top achievements
Rank 1
answered on 13 Aug 2012, 04:16 PM
I have some error....  :-(
0
Wim
Top achievements
Rank 1
answered on 20 Sep 2012, 11:27 AM
Any updates on the issue ?
0
Victor
Telerik team
answered on 21 Sep 2012, 09:46 AM
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.

Tags
Diagnostics
Asked by
Wim
Top achievements
Rank 1
Answers by
Wim
Top achievements
Rank 1
Victor
Telerik team
Omar
Top achievements
Rank 1
Share this question
or