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
361 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
Comment Utility
Hi! In your page load event, declare this.

this.CheckForIllegalCrossThreadCalls = False;
0
 
LVL 6

Accepted Solution

by:
Cebik earned 500 total points
Comment Utility
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
Comment Utility
Upss.. it's ASP.. but U can try
0

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

763 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

12 Experts available now in Live!

Get 1:1 Help Now