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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
.NET Enums [Flags] & Bitwise Design Question 6 39
C# Linq Select From List 3 48
Securing WEBAPI on Azure 2 28
T-SQL and CLR parameter strings 9 30
Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
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
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

726 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