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

MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

Question has a verified solution.

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

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…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
This is a high-level webinar that covers the history of enterprise open source database use. It addresses both the advantages companies see in using open source database technologies, as well as the fears and reservations they might have. In this…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…

691 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