StrataFrame Forum

Cross-thread operation not valid

http://forum.strataframe.net/Topic19573.aspx

By Leonard P. - 9/20/2008

Hi,



I am implementing clickable context menu with InfoBox. I am getting an error in Dispose when form is being closed after a user clicked on the context menu item. The error is "Cross-thread operation not valid: Control 'cmNotification' accessed from a thread other than the thread it was created on."



It's also happening in StrataFrame UI Control sample. But the strangest thing is that it happens in C# version of the sample only, I tired VB.NET version and it's working there Doze ?






By Dustin Taylor - 9/22/2008

Howdy Leonard Smile,

Yep, I was able to reproduce that error in the StrataFrame UI sample, so I will definately add it to the list of things to look at. That particular sample is getting a little long in the tooth, so I'm not sure whether the issue is with the implimentation or with the underlying source, but we'll look into it and let you know.

Thanks!

By Leonard P. - 9/22/2008

Thanks Dustin,



FYI, I tried adding InvokeRequired() check and BeginInvoke call to the menu onClick event, but that didn't seem to make a difference. I hope you have better luck with it.

I have a feeling the problem has to do with Context menu being created on UI thread and accessed on the InfoBox thread. It'd be interesting to know why it works in VB.NET and not in C#, please let me know how it turns out.





Thanks.