private static IPendingHandler CallPendingBox(string message, string caption, bool canCancel, Window owner) { PendingHanlderImpl handler = new PendingHanlderImpl(); var interact = Configurations.InteractOwnerMask; var content = Configurations.CancelButtonContent; InteractOwnerMask(owner, interact, true); if (Configurations.CreateOnNewThread) { PendingWindow pendingWindow = null; var autoReset = new AutoResetEvent(false); var ownerRect = GetOwnerRect(owner); var threadStart = new ThreadStart(() => { pendingWindow = new PendingWindow(message, caption, canCancel, ownerRect, content); handler.SetWindow(pendingWindow); pendingWindow.UserCancelling += (s, e) => { handler.RaiseCancellingEvent(s, e); }; pendingWindow.Closed += delegate { pendingWindow.Dispatcher.InvokeShutdown(); }; pendingWindow.Show(); autoReset.Set(); Dispatcher.Run(); }); threadStart += () => { InteractOwnerMask(owner, interact, false); handler.RaiseClosedEvent(); }; var thread = new Thread(threadStart); thread.SetApartmentState(ApartmentState.STA); thread.IsBackground = true; thread.Start(); autoReset.WaitOne(); } else { var pendingWindow = new PendingWindow(message, caption, canCancel, owner, content); pendingWindow.UserCancelling += (s, e) => { handler.RaiseCancellingEvent(s, e); }; pendingWindow.Closed += delegate { handler.RaiseClosedEvent(); InteractOwnerMask(owner, interact, false); }; pendingWindow.Show(); handler.SetWindow(pendingWindow); } return(handler); }
public void SetWindow(PendingWindow pendingWindow) { _pendingWindow = pendingWindow; }