为什么调用MessageBox.Show挂起我的应用程序?

时间:2015-09-09 07:17:07

标签: .net winforms concurrency

我有一个.NET winforms应用程序,其中包含以下代码:

    private void bindingNavigatorDeleteItem_Click(object sender, EventArgs e)
    {
        this.BeginInvoke(new MethodInvoker(DeleteCurrentIssue));
    }

    void DeleteCurrentIssue()
    {
        RequestsEntity item = (RequestsEntity)(requestsCollectionBindingSource.Current);
        if (item != null)
        {
            if (MessageBox.Show(this, "Are you sure you wish to delete this request?", "Delete Request", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.Yes)
            {
                RequestsEntity entity = new RequestsEntity(item.RequestId);
                requestsCollectionBindingSource.EndEdit();
                requestsCollectionBindingSource.RemoveCurrent();
                item.Delete();
            }
        }
    }

在显示消息框之前,代码在MessageBox.Show行上停止执行。

(添加了BeginInvoke以尝试解决此问题 - 最初代码直接在处理程序中)

我的问题似乎与: MessageBox hangs

如果我删除了MessageBox的父窗口(没有'this'参数),那么我只会占用大约10%的时间。

我认为这是一个并发问题,有些东西阻止了我的UI线程。还有一个有趣的小问题 - 如果我按下ALT键一次,会出现MessageBox,我可以继续我的程序。

更新:

这是追踪。看起来我的UI控件和ORM以有问题的方式进行交互。

mscorlib.dll!System.Collections.Generic.Dictionary<string, System.Guid>.Remove(string key)  Unknown
SD.LLBLGen.Pro.ORMSupportClasses.NET20.dll!SD.LLBLGen.Pro.ORMSupportClasses.EntityCore<System.__Canon>.UnsetEntitySyncInformation(string fieldName, SD.LLBLGen.Pro.ORMSupportClasses.IEntityCore relatedEntity, SD.LLBLGen.Pro.ORMSupportClasses.IEntityRelation relation)  Unknown
SD.LLBLGen.Pro.ORMSupportClasses.NET20.dll!SD.LLBLGen.Pro.ORMSupportClasses.EntityCore<SD.LLBLGen.Pro.ORMSupportClasses.IEntityFields>.PerformDesetupSyncRelatedEntity(SD.LLBLGen.Pro.ORMSupportClasses.IEntityCore relatedEntity, System.ComponentModel.PropertyChangedEventHandler propertiesChangedHandler, string fieldName, SD.LLBLGen.Pro.ORMSupportClasses.IEntityRelation relation, bool disconnectFromSaveEvent, bool signalRelatedEntity, string fieldInRelatedEntity, bool resetFKFields, int[] fkFieldIndexes)  Unknown
AcademicStandards.Data.dll!AcademicStandards.Data.EntityClasses.RequestsEntity.DesetupSyncDepartment(bool signalRelatedEntity, bool resetFKFields) Line 654 C#
AcademicStandards.Data.dll!AcademicStandards.Data.EntityClasses.RequestsEntity.SetupSyncDepartment(SD.LLBLGen.Pro.ORMSupportClasses.IEntityCore relatedEntity) Line 664 C#
AcademicStandards.Data.dll!AcademicStandards.Data.EntityClasses.RequestsEntity.SetRelatedEntity(SD.LLBLGen.Pro.ORMSupportClasses.IEntityCore relatedEntity, string fieldName) Line 275  C#
SD.LLBLGen.Pro.ORMSupportClasses.NET20.dll!SD.LLBLGen.Pro.ORMSupportClasses.EntityCore<System.__Canon>.SD.LLBLGen.Pro.ORMSupportClasses.IEntityCore.SetRelatedEntity(SD.LLBLGen.Pro.ORMSupportClasses.IEntityCore relatedEntity, string fieldName)  Unknown
SD.LLBLGen.Pro.ORMSupportClasses.NET20.dll!SD.LLBLGen.Pro.ORMSupportClasses.EntityCollectionBase<AcademicStandards.Data.EntityClasses.RequestsEntity>.PerformSetRelatedEntity(AcademicStandards.Data.EntityClasses.RequestsEntity entity)   Unknown
SD.LLBLGen.Pro.ORMSupportClasses.NET20.dll!SD.LLBLGen.Pro.ORMSupportClasses.CollectionCore<AcademicStandards.Data.EntityClasses.RequestsEntity>.PerformAdd(AcademicStandards.Data.EntityClasses.RequestsEntity item)    Unknown
SD.LLBLGen.Pro.ORMSupportClasses.NET20.dll!SD.LLBLGen.Pro.ORMSupportClasses.CollectionCore<System.__Canon>.Add(System.__Canon item) Unknown
AcademicStandards.Data.dll!AcademicStandards.Data.EntityClasses.DepartmentsEntity.SetRelatedEntity(SD.LLBLGen.Pro.ORMSupportClasses.IEntityCore relatedEntity, string fieldName) Line 240   C#
SD.LLBLGen.Pro.ORMSupportClasses.NET20.dll!SD.LLBLGen.Pro.ORMSupportClasses.EntityCore<System.__Canon>.SD.LLBLGen.Pro.ORMSupportClasses.IEntityCore.SetRelatedEntity(SD.LLBLGen.Pro.ORMSupportClasses.IEntityCore relatedEntity, string fieldName)  Unknown
SD.LLBLGen.Pro.ORMSupportClasses.NET20.dll!SD.LLBLGen.Pro.ORMSupportClasses.EntityCore<System.__Canon>.SetSingleRelatedEntityNavigator(SD.LLBLGen.Pro.ORMSupportClasses.IEntityCore toSet, string navigatorNameInRelatedEntity, string navigatorNameInThis, SD.LLBLGen.Pro.ORMSupportClasses.IEntityCore currentValue, bool oppositeNavigatorIsPresent) Unknown
AcademicStandards.Data.dll!AcademicStandards.Data.EntityClasses.RequestsEntity.Department.set(AcademicStandards.Data.EntityClasses.DepartmentsEntity value) Line 990    C#
AcademicStandards.Data.dll!AcademicStandards.Data.EntityClasses.RequestsEntity.GetSingleDepartment(bool forceFetch) Line 478    C#
AcademicStandards.Data.dll!AcademicStandards.Data.EntityClasses.RequestsEntity.Department.get() Line 981    C#
AcademicStandards.Data.dll!AcademicStandards.Data.EntityClasses.RequestsEntity.DepartmentName.get() Line 1123   C#
[Lightweight Function]  
DevExpress.Data.v14.2.dll!DevExpress.Data.Access.DataListDescriptor.FastPropertyDescriptor.GetValue(object component)   Unknown
DevExpress.Data.v14.2.dll!DevExpress.Data.Helpers.BaseListDataControllerHelper.GetRowValue(int listSourceRow, int column, DevExpress.Data.OperationCompleted completed) Unknown
DevExpress.Data.v14.2.dll!DevExpress.Data.DataController.GetRowValue(int controllerRow, int column, DevExpress.Data.OperationCompleted completed)   Unknown
DevExpress.Data.v14.2.dll!DevExpress.Data.BaseListSourceDataController.GetRowValue(int controllerRow, int column, DevExpress.Data.OperationCompleted completed) Unknown
DevExpress.XtraGrid.v14.2.dll!DevExpress.XtraGrid.Views.Grid.GridView.GetRowCellValue(int rowHandle, DevExpress.XtraGrid.Columns.GridColumn column, DevExpress.Data.OperationCompleted completed)   Unknown
DevExpress.XtraGrid.v14.2.dll!DevExpress.XtraGrid.Views.Grid.GridView.GetRowCellValue(int rowHandle, DevExpress.XtraGrid.Columns.GridColumn column) Unknown
DevExpress.XtraGrid.v14.2.dll!DevExpress.XtraGrid.Views.Grid.ViewInfo.GridViewInfo.GetRowCellValue(DevExpress.XtraGrid.Views.Grid.ViewInfo.GridCellInfo cell, int rowHandle, DevExpress.XtraGrid.Drawing.GridColumnInfoArgs ci) Unknown
DevExpress.XtraGrid.v14.2.dll!DevExpress.XtraGrid.Views.Grid.ViewInfo.GridViewInfo.UpdateRowCells(DevExpress.XtraGrid.Views.Grid.ViewInfo.GridDataRowInfo ri, bool forPrinting) Unknown
DevExpress.XtraGrid.v14.2.dll!DevExpress.XtraGrid.Views.Grid.ViewInfo.GridViewInfo.UpdateRowData(DevExpress.XtraGrid.Views.Grid.ViewInfo.GridRowInfo bi, bool updateMouse, bool forPrinting)    Unknown
DevExpress.XtraGrid.v14.2.dll!DevExpress.XtraGrid.Views.Grid.ViewInfo.GridViewInfo.CheckRowData(DevExpress.XtraGrid.Views.Grid.ViewInfo.GridRowInfo ri) Unknown
DevExpress.XtraGrid.v14.2.dll!DevExpress.XtraGrid.Views.Grid.ViewInfo.GridViewInfo.UpdateBeforePaint(DevExpress.XtraGrid.Views.Grid.ViewInfo.GridRowInfo ri)    Unknown
DevExpress.XtraGrid.v14.2.dll!DevExpress.XtraGrid.Views.Grid.Drawing.GridPainter.DrawRow(DevExpress.XtraGrid.Views.Grid.Drawing.GridViewDrawArgs e, DevExpress.XtraGrid.Views.Grid.ViewInfo.GridRowInfo ri) Unknown
DevExpress.XtraGrid.v14.2.dll!DevExpress.XtraGrid.Views.Grid.Drawing.GridPainter.DrawRows(DevExpress.XtraGrid.Views.Grid.Drawing.GridViewDrawArgs e)    Unknown
DevExpress.XtraGrid.v14.2.dll!DevExpress.XtraGrid.Views.Grid.Drawing.GridPainter.DrawContents(DevExpress.XtraGrid.Views.Grid.Drawing.GridViewDrawArgs e)    Unknown
DevExpress.XtraGrid.v14.2.dll!DevExpress.XtraGrid.Views.Grid.Drawing.GridPainter.Draw(DevExpress.XtraGrid.Views.Base.ViewDrawArgs ee)   Unknown
DevExpress.XtraGrid.v14.2.dll!DevExpress.XtraGrid.Views.Base.BaseView.Draw(DevExpress.Utils.Drawing.GraphicsCache e)    Unknown
DevExpress.XtraGrid.v14.2.dll!DevExpress.XtraGrid.GridControl.OnPaint(System.Windows.Forms.PaintEventArgs e)    Unknown
DevExpress.Utils.v14.2.dll!DevExpress.Utils.Drawing.ControlPaintHelper.PaintWithErrorHandling(System.Windows.Forms.PaintEventArgs paintEventArgs, int layer)    Unknown
DevExpress.Utils.v14.2.dll!DevExpress.Utils.Drawing.ControlPaintHelper.ProcessWMPaint(ref System.Windows.Forms.Message m)   Unknown
DevExpress.XtraGrid.v14.2.dll!DevExpress.XtraGrid.GridControl.CheckProcessMsg(ref System.Windows.Forms.Message m)   Unknown
DevExpress.XtraGrid.v14.2.dll!DevExpress.XtraGrid.GridControl.WndProc(ref System.Windows.Forms.Message m)   Unknown
System.Windows.Forms.dll!System.Windows.Forms.Control.ControlNativeWindow.OnMessage(ref System.Windows.Forms.Message m) Unknown
System.Windows.Forms.dll!System.Windows.Forms.Control.ControlNativeWindow.WndProc(ref System.Windows.Forms.Message m)   Unknown
System.Windows.Forms.dll!System.Windows.Forms.NativeWindow.DebuggableCallback(System.IntPtr hWnd, int msg, System.IntPtr wparam, System.IntPtr lparam)  Unknown
[Native to Managed Transition]  
user32.dll!__InternalCallWinProc@20()   Unknown
user32.dll!_UserCallWinProcCheckWow@36()    Unknown
user32.dll!_DispatchClientMessage@24()  Unknown
user32.dll!___fnDWORD@4()   Unknown
ntdll.dll!_KiUserCallbackDispatcher@12()    Unknown
user32.dll!_DialogBox2@16() Unknown
user32.dll!_InternalDialogBox@24()  Unknown
user32.dll!_SoftModalMessageBox@4() Unknown
user32.dll!_MessageBoxWorker@4()    Unknown
user32.dll!_MessageBoxTimeoutW@24() Unknown
user32.dll!_MessageBoxExW@20()  Unknown
user32.dll!_MessageBoxW@16()    Unknown
System.Windows.Forms.ni.dll!666128f0()  Unknown
[Frames below may be incorrect and/or missing, native debugger attempting to walk managed call stack]   
[Managed to Native Transition]  
System.Windows.Forms.dll!System.Windows.Forms.MessageBox.ShowCore(System.Windows.Forms.IWin32Window owner, string text, string caption, System.Windows.Forms.MessageBoxButtons buttons, System.Windows.Forms.MessageBoxIcon icon, System.Windows.Forms.MessageBoxDefaultButton defaultButton, System.Windows.Forms.MessageBoxOptions options, bool showHelp)    Unknown
System.Windows.Forms.dll!System.Windows.Forms.MessageBox.Show(System.Windows.Forms.IWin32Window owner, string text, string caption, System.Windows.Forms.MessageBoxButtons buttons, System.Windows.Forms.MessageBoxIcon icon, System.Windows.Forms.MessageBoxDefaultButton defaultButton)   Unknown
AcademicStandards.exe!AcademicStandards.MainForm.DeleteCurrentIssue() Line 295  C#
System.Windows.Forms.dll!System.Windows.Forms.Control.InvokeMarshaledCallbackDo(System.Windows.Forms.Control.ThreadMethodEntry tme) Unknown
System.Windows.Forms.dll!System.Windows.Forms.Control.InvokeMarshaledCallbackHelper(object obj) Unknown
mscorlib.dll!System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, object state, bool preserveSyncCtx)   Unknown
mscorlib.dll!System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, object state, bool preserveSyncCtx)   Unknown
mscorlib.dll!System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, object state) Unknown
System.Windows.Forms.dll!System.Windows.Forms.Control.InvokeMarshaledCallback(System.Windows.Forms.Control.ThreadMethodEntry tme)   Unknown
System.Windows.Forms.dll!System.Windows.Forms.Control.InvokeMarshaledCallbacks()    Unknown
System.Windows.Forms.dll!System.Windows.Forms.Control.WndProc(ref System.Windows.Forms.Message m)   Unknown
System.Windows.Forms.dll!System.Windows.Forms.ScrollableControl.WndProc(ref System.Windows.Forms.Message m) Unknown
System.Windows.Forms.dll!System.Windows.Forms.Form.WndProc(ref System.Windows.Forms.Message m)  Unknown
System.Windows.Forms.dll!System.Windows.Forms.Control.ControlNativeWindow.OnMessage(ref System.Windows.Forms.Message m) Unknown
System.Windows.Forms.dll!System.Windows.Forms.Control.ControlNativeWindow.WndProc(ref System.Windows.Forms.Message m)   Unknown
System.Windows.Forms.dll!System.Windows.Forms.NativeWindow.DebuggableCallback(System.IntPtr hWnd, int msg, System.IntPtr wparam, System.IntPtr lparam)  Unknown
[Native to Managed Transition]  
user32.dll!__InternalCallWinProc@20()   Unknown
user32.dll!_UserCallWinProcCheckWow@36()    Unknown
user32.dll!_DispatchMessageWorker@8()   Unknown
user32.dll!_DispatchMessageW@4()    Unknown
System.Windows.Forms.ni.dll!660eeffc()  Unknown
[Managed to Native Transition]  


System.Windows.Forms.dll!System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(System.IntPtr dwComponentID, int reason, int pvLoopData)  Unknown
    System.Windows.Forms.dll!System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(int reason, System.Windows.Forms.ApplicationContext context)    Unknown
    System.Windows.Forms.dll!System.Windows.Forms.Application.ThreadContext.RunMessageLoop(int reason, System.Windows.Forms.ApplicationContext context) Unknown
    System.Windows.Forms.dll!System.Windows.Forms.Application.Run(System.Windows.Forms.Form mainForm)   Unknown
>   AcademicStandards.exe!AcademicStandards.Program.Main() Line 53  C#
    [Native to Managed Transition]  
    mscoreei.dll!__CorExeMain@0()   Unknown
    mscoree.dll!__CorExeMain_Exported@0()   Unknown
    kernel32.dll!@BaseThreadInitThunk@12()  Unknown
    ntdll.dll!__RtlUserThreadStart()    Unknown
    ntdll.dll!__RtlUserThreadStart@8()  Unknown

这是另一个不同点的第二条痕迹:

    ntdll.dll!_NtWaitForSingleObject@12()   Unknown
    KernelBase.dll!_WaitForSingleObjectEx@12()  Unknown
    mscorlib.ni.dll!728883e3()  Unknown
    [Frames below may be incorrect and/or missing, native debugger attempting to walk managed call stack]   
    [Managed to Native Transition]  
    mscorlib.dll!System.Type.IsVisible.get()    Unknown
    System.dll!System.SecurityUtils.MethodInfoInvoke(System.Reflection.MethodInfo method, object target, object[] args) Unknown
    System.dll!System.ComponentModel.ReflectPropertyDescriptor.GetValue(object component)   Unknown
    System.Windows.Forms.dll!System.Windows.Forms.BindToObject.GetValue()   Unknown
    System.Windows.Forms.dll!System.Windows.Forms.Binding.PushData(bool force)  Unknown
    System.Windows.Forms.dll!System.Windows.Forms.BindingManagerBase.PushData(out bool success) Unknown
    System.Windows.Forms.dll!System.Windows.Forms.CurrencyManager.CurrencyManager_PushData()    Unknown
    System.Windows.Forms.dll!System.Windows.Forms.CurrencyManager.OnItemChanged(System.Windows.Forms.ItemChangedEventArgs e)    Unknown
    System.Windows.Forms.dll!System.Windows.Forms.CurrencyManager.List_ListChanged(object sender, System.ComponentModel.ListChangedEventArgs e) Unknown
    System.Windows.Forms.dll!System.Windows.Forms.BindingSource.OnListChanged(System.ComponentModel.ListChangedEventArgs e) Unknown
    System.Windows.Forms.dll!System.Windows.Forms.BindingSource.ListItem_PropertyChanged(object sender, System.EventArgs e) Unknown
    System.dll!System.ComponentModel.PropertyDescriptor.OnValueChanged(object component, System.EventArgs e)    Unknown
    System.dll!System.ComponentModel.ReflectPropertyDescriptor.OnValueChanged(object component, System.EventArgs e) Unknown
    System.dll!System.ComponentModel.ReflectPropertyDescriptor.OnINotifyPropertyChanged(object component, System.ComponentModel.PropertyChangedEventArgs e) Unknown
    SD.LLBLGen.Pro.ORMSupportClasses.NET20.dll!SD.LLBLGen.Pro.ORMSupportClasses.EntityCore<System.__Canon>.OnPropertyChanged(string propertyName)   Unknown
    SD.LLBLGen.Pro.ORMSupportClasses.NET20.dll!SD.LLBLGen.Pro.ORMSupportClasses.EntityCore<System.__Canon>.PerformSetupSyncRelatedEntity(SD.LLBLGen.Pro.ORMSupportClasses.IEntityCore relatedEntity, System.ComponentModel.PropertyChangedEventHandler propertiesChangedHandler, string fieldName, SD.LLBLGen.Pro.ORMSupportClasses.IEntityRelation relation, bool connectToSaveEvent, ref bool alreadyFetchedFlag, string[] forfNames) Unknown
>   AcademicStandards.Data.dll!AcademicStandards.Data.EntityClasses.RequestsEntity.SetupSyncDepartment(SD.LLBLGen.Pro.ORMSupportClasses.IEntityCore relatedEntity) Line 666 C#
    AcademicStandards.Data.dll!AcademicStandards.Data.EntityClasses.RequestsEntity.SetRelatedEntity(SD.LLBLGen.Pro.ORMSupportClasses.IEntityCore relatedEntity, string fieldName) Line 275  C#
    SD.LLBLGen.Pro.ORMSupportClasses.NET20.dll!SD.LLBLGen.Pro.ORMSupportClasses.EntityCore<System.__Canon>.SD.LLBLGen.Pro.ORMSupportClasses.IEntityCore.SetRelatedEntity(SD.LLBLGen.Pro.ORMSupportClasses.IEntityCore relatedEntity, string fieldName)  Unknown
    SD.LLBLGen.Pro.ORMSupportClasses.NET20.dll!SD.LLBLGen.Pro.ORMSupportClasses.EntityCollectionBase<AcademicStandards.Data.EntityClasses.RequestsEntity>.PerformSetRelatedEntity(AcademicStandards.Data.EntityClasses.RequestsEntity entity)   Unknown
    SD.LLBLGen.Pro.ORMSupportClasses.NET20.dll!SD.LLBLGen.Pro.ORMSupportClasses.CollectionCore<AcademicStandards.Data.EntityClasses.RequestsEntity>.PerformAdd(AcademicStandards.Data.EntityClasses.RequestsEntity item)    Unknown
    SD.LLBLGen.Pro.ORMSupportClasses.NET20.dll!SD.LLBLGen.Pro.ORMSupportClasses.CollectionCore<System.__Canon>.Add(System.__Canon item) Unknown
    AcademicStandards.Data.dll!AcademicStandards.Data.EntityClasses.DepartmentsEntity.SetRelatedEntity(SD.LLBLGen.Pro.ORMSupportClasses.IEntityCore relatedEntity, string fieldName) Line 240   C#
    SD.LLBLGen.Pro.ORMSupportClasses.NET20.dll!SD.LLBLGen.Pro.ORMSupportClasses.EntityCore<System.__Canon>.SD.LLBLGen.Pro.ORMSupportClasses.IEntityCore.SetRelatedEntity(SD.LLBLGen.Pro.ORMSupportClasses.IEntityCore relatedEntity, string fieldName)  Unknown
    SD.LLBLGen.Pro.ORMSupportClasses.NET20.dll!SD.LLBLGen.Pro.ORMSupportClasses.EntityCore<System.__Canon>.SetSingleRelatedEntityNavigator(SD.LLBLGen.Pro.ORMSupportClasses.IEntityCore toSet, string navigatorNameInRelatedEntity, string navigatorNameInThis, SD.LLBLGen.Pro.ORMSupportClasses.IEntityCore currentValue, bool oppositeNavigatorIsPresent) Unknown
    AcademicStandards.Data.dll!AcademicStandards.Data.EntityClasses.RequestsEntity.Department.set(AcademicStandards.Data.EntityClasses.DepartmentsEntity value) Line 990    C#
    AcademicStandards.Data.dll!AcademicStandards.Data.EntityClasses.RequestsEntity.GetSingleDepartment(bool forceFetch) Line 478    C#
    AcademicStandards.Data.dll!AcademicStandards.Data.EntityClasses.RequestsEntity.Department.get() Line 981    C#
    AcademicStandards.Data.dll!AcademicStandards.Data.EntityClasses.RequestsEntity.DepartmentName.get() Line 1123   C#
    [Lightweight Function]  
    DevExpress.Data.v14.2.dll!DevExpress.Data.Access.DataListDescriptor.FastPropertyDescriptor.GetValue(object component)   Unknown
    DevExpress.Data.v14.2.dll!DevExpress.Data.Helpers.BaseListDataControllerHelper.GetRowValue(int listSourceRow, int column, DevExpress.Data.OperationCompleted completed) Unknown
    DevExpress.Data.v14.2.dll!DevExpress.Data.DataController.GetRowValue(int controllerRow, int column, DevExpress.Data.OperationCompleted completed)   Unknown
    DevExpress.Data.v14.2.dll!DevExpress.Data.BaseListSourceDataController.GetRowValue(int controllerRow, int column, DevExpress.Data.OperationCompleted completed) Unknown
    DevExpress.XtraGrid.v14.2.dll!DevExpress.XtraGrid.Views.Grid.GridView.GetRowCellValue(int rowHandle, DevExpress.XtraGrid.Columns.GridColumn column, DevExpress.Data.OperationCompleted completed)   Unknown
    DevExpress.XtraGrid.v14.2.dll!DevExpress.XtraGrid.Views.Grid.GridView.GetRowCellValue(int rowHandle, DevExpress.XtraGrid.Columns.GridColumn column) Unknown
    DevExpress.XtraGrid.v14.2.dll!DevExpress.XtraGrid.Views.Grid.ViewInfo.GridViewInfo.GetRowCellValue(DevExpress.XtraGrid.Views.Grid.ViewInfo.GridCellInfo cell, int rowHandle, DevExpress.XtraGrid.Drawing.GridColumnInfoArgs ci) Unknown
    DevExpress.XtraGrid.v14.2.dll!DevExpress.XtraGrid.Views.Grid.ViewInfo.GridViewInfo.UpdateRowCells(DevExpress.XtraGrid.Views.Grid.ViewInfo.GridDataRowInfo ri, bool forPrinting) Unknown
    DevExpress.XtraGrid.v14.2.dll!DevExpress.XtraGrid.Views.Grid.ViewInfo.GridViewInfo.UpdateRowData(DevExpress.XtraGrid.Views.Grid.ViewInfo.GridRowInfo bi, bool updateMouse, bool forPrinting)    Unknown
    DevExpress.XtraGrid.v14.2.dll!DevExpress.XtraGrid.Views.Grid.ViewInfo.GridViewInfo.CheckRowData(DevExpress.XtraGrid.Views.Grid.ViewInfo.GridRowInfo ri) Unknown
    DevExpress.XtraGrid.v14.2.dll!DevExpress.XtraGrid.Views.Grid.ViewInfo.GridViewInfo.UpdateBeforePaint(DevExpress.XtraGrid.Views.Grid.ViewInfo.GridRowInfo ri)    Unknown
    DevExpress.XtraGrid.v14.2.dll!DevExpress.XtraGrid.Views.Grid.Drawing.GridPainter.DrawRow(DevExpress.XtraGrid.Views.Grid.Drawing.GridViewDrawArgs e, DevExpress.XtraGrid.Views.Grid.ViewInfo.GridRowInfo ri) Unknown
    DevExpress.XtraGrid.v14.2.dll!DevExpress.XtraGrid.Views.Grid.Drawing.GridPainter.DrawRows(DevExpress.XtraGrid.Views.Grid.Drawing.GridViewDrawArgs e)    Unknown
    DevExpress.XtraGrid.v14.2.dll!DevExpress.XtraGrid.Views.Grid.Drawing.GridPainter.DrawContents(DevExpress.XtraGrid.Views.Grid.Drawing.GridViewDrawArgs e)    Unknown
    DevExpress.XtraGrid.v14.2.dll!DevExpress.XtraGrid.Views.Grid.Drawing.GridPainter.Draw(DevExpress.XtraGrid.Views.Base.ViewDrawArgs ee)   Unknown
    DevExpress.XtraGrid.v14.2.dll!DevExpress.XtraGrid.Views.Base.BaseView.Draw(DevExpress.Utils.Drawing.GraphicsCache e)    Unknown
    DevExpress.XtraGrid.v14.2.dll!DevExpress.XtraGrid.GridControl.OnPaint(System.Windows.Forms.PaintEventArgs e)    Unknown
    DevExpress.Utils.v14.2.dll!DevExpress.Utils.Drawing.ControlPaintHelper.PaintWithErrorHandling(System.Windows.Forms.PaintEventArgs paintEventArgs, int layer)    Unknown
    DevExpress.Utils.v14.2.dll!DevExpress.Utils.Drawing.ControlPaintHelper.ProcessWMPaint(ref System.Windows.Forms.Message m)   Unknown
    DevExpress.XtraGrid.v14.2.dll!DevExpress.XtraGrid.GridControl.CheckProcessMsg(ref System.Windows.Forms.Message m)   Unknown
    DevExpress.XtraGrid.v14.2.dll!DevExpress.XtraGrid.GridControl.WndProc(ref System.Windows.Forms.Message m)   Unknown
    System.Windows.Forms.dll!System.Windows.Forms.Control.ControlNativeWindow.OnMessage(ref System.Windows.Forms.Message m) Unknown
    System.Windows.Forms.dll!System.Windows.Forms.Control.ControlNativeWindow.WndProc(ref System.Windows.Forms.Message m)   Unknown
    System.Windows.Forms.dll!System.Windows.Forms.NativeWindow.DebuggableCallback(System.IntPtr hWnd, int msg, System.IntPtr wparam, System.IntPtr lparam)  Unknown
    [Native to Managed Transition]  
    user32.dll!__InternalCallWinProc@20()   Unknown
    user32.dll!_UserCallWinProcCheckWow@36()    Unknown
    user32.dll!_DispatchClientMessage@24()  Unknown
    user32.dll!___fnDWORD@4()   Unknown
    ntdll.dll!_KiUserCallbackDispatcher@12()    Unknown
    user32.dll!_DialogBox2@16() Unknown
    user32.dll!_InternalDialogBox@24()  Unknown
    user32.dll!_SoftModalMessageBox@4() Unknown
    user32.dll!_MessageBoxWorker@4()    Unknown
    user32.dll!_MessageBoxTimeoutW@24() Unknown
    user32.dll!_MessageBoxExW@20()  Unknown
    user32.dll!_MessageBoxW@16()    Unknown
    System.Windows.Forms.ni.dll!666128f0()  Unknown
    [Managed to Native Transition]  
    System.Windows.Forms.dll!System.Windows.Forms.MessageBox.ShowCore(System.Windows.Forms.IWin32Window owner, string text, string caption, System.Windows.Forms.MessageBoxButtons buttons, System.Windows.Forms.MessageBoxIcon icon, System.Windows.Forms.MessageBoxDefaultButton defaultButton, System.Windows.Forms.MessageBoxOptions options, bool showHelp)    Unknown
    System.Windows.Forms.dll!System.Windows.Forms.MessageBox.Show(System.Windows.Forms.IWin32Window owner, string text, string caption, System.Windows.Forms.MessageBoxButtons buttons, System.Windows.Forms.MessageBoxIcon icon, System.Windows.Forms.MessageBoxDefaultButton defaultButton)   Unknown
    AcademicStandards.exe!AcademicStandards.MainForm.DeleteCurrentIssue() Line 295  C#
    System.Windows.Forms.dll!System.Windows.Forms.Control.InvokeMarshaledCallbackDo(System.Windows.Forms.Control.ThreadMethodEntry tme) Unknown
    System.Windows.Forms.dll!System.Windows.Forms.Control.InvokeMarshaledCallbackHelper(object obj) Unknown
    mscorlib.dll!System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, object state, bool preserveSyncCtx)   Unknown
    mscorlib.dll!System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, object state, bool preserveSyncCtx)   Unknown
    mscorlib.dll!System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, object state) Unknown
    System.Windows.Forms.dll!System.Windows.Forms.Control.InvokeMarshaledCallback(System.Windows.Forms.Control.ThreadMethodEntry tme)   Unknown
    System.Windows.Forms.dll!System.Windows.Forms.Control.InvokeMarshaledCallbacks()    Unknown
    System.Windows.Forms.dll!System.Windows.Forms.Control.WndProc(ref System.Windows.Forms.Message m)   Unknown
    System.Windows.Forms.dll!System.Windows.Forms.ScrollableControl.WndProc(ref System.Windows.Forms.Message m) Unknown
    System.Windows.Forms.dll!System.Windows.Forms.Form.WndProc(ref System.Windows.Forms.Message m)  Unknown
    System.Windows.Forms.dll!System.Windows.Forms.Control.ControlNativeWindow.OnMessage(ref System.Windows.Forms.Message m) Unknown
    System.Windows.Forms.dll!System.Windows.Forms.Control.ControlNativeWindow.WndProc(ref System.Windows.Forms.Message m)   Unknown
    System.Windows.Forms.dll!System.Windows.Forms.NativeWindow.DebuggableCallback(System.IntPtr hWnd, int msg, System.IntPtr wparam, System.IntPtr lparam)  Unknown
    [Native to Managed Transition]  
    user32.dll!__InternalCallWinProc@20()   Unknown
    user32.dll!_UserCallWinProcCheckWow@36()    Unknown
    user32.dll!_DispatchMessageWorker@8()   Unknown
    user32.dll!_DispatchMessageW@4()    Unknown
    System.Windows.Forms.ni.dll!660eeffc()  Unknown
    [Managed to Native Transition]  
    System.Windows.Forms.dll!System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(System.IntPtr dwComponentID, int reason, int pvLoopData)  Unknown
    System.Windows.Forms.dll!System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(int reason, System.Windows.Forms.ApplicationContext context)    Unknown
    System.Windows.Forms.dll!System.Windows.Forms.Application.ThreadContext.RunMessageLoop(int reason, System.Windows.Forms.ApplicationContext context) Unknown
    System.Windows.Forms.dll!System.Windows.Forms.Application.Run(System.Windows.Forms.Form mainForm)   Unknown
    AcademicStandards.exe!AcademicStandards.Program.Main() Line 53  C#
    [Native to Managed Transition]  
    mscoreei.dll!__CorExeMain@0()   Unknown
    mscoree.dll!__CorExeMain_Exported@0()   Unknown
    kernel32.dll!@BaseThreadInitThunk@12()  Unknown
    ntdll.dll!__RtlUserThreadStart()    Unknown
    ntdll.dll!__RtlUserThreadStart@8()  Unknown

2 个答案:

答案 0 :(得分:1)

我设法用一些help from another forum来解决这个问题。问题是父窗口上的所有UI控件都在显示之前从MessageBox获取重绘事件(标准行为)。但在这种情况下,UI控件重绘在我的ORM库中触发了ListChanged事件。然后,ListChanged事件触发了UI重绘,从而导致无限循环的消息。

显然,MessageBox UI中的消息泵无法处理自己的绘制事件。因此,我得到了&#34;模态&#34;没有框本身的MessageBox的效果。该应用程序并未完全冻结,但正在等待对从未绘制过的模态对话框的响应。

我通过重构调用我的ORM库的代码解决了这个问题,避免了ListChanged事件。

答案 1 :(得分:0)

所以看起来你的MessageBox出现了,但被某些东西隐藏了,很可能是你展示它的窗口。调试此类事情并不容易,但您可以尝试以下方法:

  1. 尝试使用this.BringToFront();
  2. 将您的控件置于最前面
  3. 尝试使用以下技巧:

    MessageBox.Show(new Form() { TopMost = true }, "Are you sure you wish to delete this request?"...);
    
  4. 它将创建新的最顶层表单并显示相对于它的MessageBox,因此它应始终显示在所有表单的顶部。