?
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
Medium Priority
?
370 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 2000 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

DFW AZURE MEETUP TONIGHT FRI 6PM

We will be discussing what Azure Stack is, how does it fit into the suit of offerings that Azure has currently, and where can it fit into your organizations technology stack. We will also be discussing limitations of the platform while covering various applicable scenarios.

Question has a verified solution.

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

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.
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses

770 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