activating a custom new window while debuging in visual studio
in code below I show information on my application , if there is something that was not set
(...in one of the classes or methods) correctly a window pops up with the current message telling what was missing .
there is only one problem I wonder if and how could this be done, the application is frozen while still debugging so I can not move the window or click on it's control,
is there any workaround you think of I could apply ?
new System.Threading.Thread(() => ProcessSomeLongRunningTask()).Start();
//then from another helper class
Application.Current.Dispatcher.Invoke(new Action(() =>CustomW.MsgBoxShow(" Title ", "Msg")), System.Windows.Threading.DispatcherPriority.Normal);
The issue here is that you're processing your message box on your main dispatcher thread and as you know this defaults as a dialog box and steals focus from the main application window.
So you could try executing the message box in the new thread you create or you could create your own custom user control with the same features as the message box but it won't inherit that tools behavior.
You can still run it from a secondary thread like you created, but remember to wrap anything that interacts with objects made by the main dispatcher as a delegate action
public void LongProcess()
Thread t = new Thread(new ThreadStart(
//Complex code goes here
//Any requests for controls or variables that you need
//from the main application running on the main dispatcher
//Finally once you've got the information to return to
//your user call a message box here and populate the
//If a message box fails or isn't good enough
//create your own user control and call it here like:
usrConMessage msg = new usrConMessage();
msg.strTitle = "Whatever";
msg.strContent = "Whatever";
msg.show(); //Not a dialog so doesn't steal focus
//That is normally how I would go about providing a
//unique and polished user experience.
Asked in February 2016Viewed 3,454 timesVoted 9Answered 1 times