سؤال

I am using Telerik's radcontrols for winforms.

Here is a program that can reproduce my problem:

public partial class RadForm1 : Telerik.WinControls.UI.RadForm
{
    public RadForm1()
    {
        InitializeComponent();
    }

    private void radButton1_Click(object sender, EventArgs e)
    {
        RadMessageBox.SetThemeName("Office2010Black");
        RadMessageBox.Show("Hello World");
        //MessageBox.Show("hello world");
        run();
    }

    public void run()
    {
        var thread = new Thread(() => run2());
        thread.IsBackground = true;
        thread.Start();
    }

    public void run2()
    {
        //MessageBox.Show("hello");
        RadMessageBox.Show("Hello");
    }
}

Whenever try using Telerik's messagebox I am getting a cross thread exception. However if I use the standard winform messagebox instead then it will work absolutely fine.

Maybe i am missing something here.

UPDATE:

for anyone else having the same problem this is the link to offical reply Click here

هل كانت مفيدة؟

المحلول

The winform MessageBox class is specifically designed to be able to be called from a non-UI thread.

The RadMessageBox simply wasn't. It was designed under the assumption that it would be called from the UI thread.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top