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
363 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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

Suggested Solutions

In my previous two articles we discussed Binary Serialization (http://www.experts-exchange.com/A_4362.html) and XML Serialization (http://www.experts-exchange.com/A_4425.html). In this article we will try to know more about SOAP (Simple Object Acces…
This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
In this video I am going to show you how to back up and restore Office 365 mailboxes using CodeTwo Backup for Office 365. Learn more about the tool used in this video here: http://www.codetwo.com/backup-for-office-365/ (http://www.codetwo.com/ba…
In a recent question (https://www.experts-exchange.com/questions/28997919/Pagination-in-Adobe-Acrobat.html) here at Experts Exchange, a member asked how to add page numbers to a PDF file using Adobe Acrobat XI Pro. This short video Micro Tutorial sh…

813 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

10 Experts available now in Live!

Get 1:1 Help Now