Group: StrataFrame Users
Posts: 193,
Visits: 9K
|
Hi, under certain condition, the main menu in my MDI form may call an infobox with a contextmenu .
If lnReccount > 5000 ThenWith InfoBox.NotifyBoxSettings.CardinalPosition = MessagingCardinalPosition.NorthWest .SpecialEffect = InfoBoxSpecialEffect.Fade .Opacity = 80 End WithInfoBox.NotifyBox(lcTitre, lcMessage, Me, Me.ThemedContextMenuStripInfoBox, MessagingCardinalPosition.NorthWest)End If Here's the code for one item
Private Sub CuvesToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CuvesToolStripMenuItem.Click, showCuvesTrue.ClickDim frmCuves As New formcuvesfrmCuves.MdiParent = MefrmCuves.Show() End Sub And of course, I get an error because I'm not on the required thread:
InvalidOperationException Opération inter-threads non valide : le contrôle 'Ecran' a fait l'objet d'un accès à partir d'un thread autre que celui sur lequel il a été créé. Source : System.Windows.Forms Stack Trace: à System.Windows.Forms.Control.get_Handle() à System.Windows.Forms.Control.get_CreateThreadId() à System.Windows.Forms.Form.set_MdiParentInternal(Form value) à System.Windows.Forms.Form.set_MdiParent(Form value) à bcuvtest1.Ecran.CuvesToolStripMenuItem_Click(Object sender, EventArgs e) dans C:\Documents and Settings\MICHEL\Mes documents\Visual Studio 2005\Projects\bcuvtest1\bcuvtest1\Ecran.vb:ligne 77 à System.Windows.Forms.ToolStripItem.RaiseEvent(Object key, EventArgs e) à System.Windows.Forms.ToolStripMenuItem.OnClick(EventArgs e) à System.Windows.Forms.ToolStripItem.HandleClick(EventArgs e) à System.Windows.Forms.ToolStripItem.HandleMouseUp(MouseEventArgs e) à System.Windows.Forms.ToolStripItem.FireEventInteractive(EventArgs e, ToolStripItemEventType met) à System.Windows.Forms.ToolStripItem.FireEvent(EventArgs e, ToolStripItemEventType met) à System.Windows.Forms.ToolStrip.OnMouseUp(MouseEventArgs mea) à System.Windows.Forms.ToolStripDropDown.OnMouseUp(MouseEventArgs mea) à System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks) à System.Windows.Forms.Control.WndProc(Message& m) à System.Windows.Forms.ScrollableControl.WndProc(Message& m) à System.Windows.Forms.ToolStrip.WndProc(Message& m) à System.Windows.Forms.ToolStripDropDown.WndProc(Message& m) à System.Windows.Forms.Control.ControlNativewindow.OnMessage(Message& m) à System.Windows.Forms.Control.ControlNativewindow.WndProc(Message& m) à System.Windows.Forms.Nativewindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam) à System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg) à System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData) à System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context) à System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context) à System.Windows.Forms.Form.ShowDialog(IWin32Window owner) à System.Windows.Forms.Form.ShowDialog() à MicroFour.StrataFrame.Messaging.InfoBox.NewAlertBoxThread() à System.Threading.ThreadHelper.ThreadStart_Context(Object state) à System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state) à System.Threading.ThreadHelper.ThreadStart()
How to ensure I'm in the "main" thread? Thanks
|