Solved

richtext.text {"Cross-thread operation not valid: Control 'txtWeeklyMarketCommentary' accessed from a thread other than the thread it was created on."}

Posted on 2009-04-01
4
362 Views
Last Modified: 2012-05-06
Im getting the error"Cross-thread operation not valid: Control 'txtWeeklyMarketCommentary' accessed from a thread other than the thread it was created on"

When trying to get the text from a richtextbox control does anyone no of another way i can  get this ???  
public object RunEBUSave()

        {

            if (MKIPlugin.Instance.ServerAvailable)

            {

                PCBBSupportService svc = new PCBBSupportService(MKIPlugin.Instance.Communication);
 

                if (marketInfochanged)

                {

                    MarketInformation marketInfo = new MarketInformation

                                                       {

                                                           InfoText = this.txtWeeklyMarketCommentary.Text,

                                                           XmlPostDateTime =

                                                               DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")

                                                       };

                    svc.PutBulletin(MKIBulletinTypes.MARKETINFO_ID, "BULLETIN", "Market Information",

                                    Encoding.UTF8.GetBytes(marketInfo.GetXmlString()));
 

                    lastUpdatedForEBU = DateTime.Now;

                }

                if (productInfoChanged)

                {

                    ProductInformation productInfo = new ProductInformation();

                    productInfo.InfoText = txtProductInformation.Text;

                    productInfo.XmlPostDateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");

                    svc.PutBulletin(MKIBulletinTypes.PRODUCTINFO_ID, "BULLETIN", "Product Information",

                                    Encoding.UTF8.GetBytes(productInfo.GetXmlString()));
 

                    lastUpdatedForEBU = DateTime.Now;

                }
 

                MKIPlugin.Instance.CommsController.DoPluginCommsProcess(

                    MKIPlugin.Instance.Communication.GetSession(false));

            }

            return null;

        }

Open in new window

0
Comment
Question by:rourkas1
  • 2
4 Comments
 
LVL 13

Expert Comment

by:drypz
ID: 24045880
Hi! In your page load event, declare this.

this.CheckForIllegalCrossThreadCalls = False;
0
 
LVL 6

Accepted Solution

by:
Cebik earned 500 total points
ID: 24055413
Add this.. and use this methode..

public delegate void UpdateTxtWeeklyMarketCommentaryCallback(string s);

public void UpdateTxtWeeklyMarketCommentary(string s)

{

    if (txtWeeklyMarketCommentary.InvokeRequired)

    {

        txtWeeklyMarketCommentary.Invoke(new UpdateTxtWeeklyMarketCommentaryCallback(this.UpdateTxtWeeklyMarketCommentary), s);

    }

    else

    {

        txtWeeklyMarketCommentary.Text = s;

        txtWeeklyMarketCommentary.Refresh();

    }

}

Open in new window

0
 
LVL 6

Expert Comment

by:Cebik
ID: 24055432
Upss.. it's ASP.. but U can try
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes relatively difficult and non-obvious issues that are likely to arise when creating COM class in Visual Studio and deploying it by professional MSI-authoring tools. It is assumed that the reader is already familiar with the cla…
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…
Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…

910 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now