Q:
1) Do you know how to cancel specific operations of the IDE when the program’s main thread is busy?
2) Could we make the other IDEs busy when the main thread turns busy so that user operations on them are prevented?
A:
>>1) Do you know how to cancel specific operations of the IDE when the program’s main thread is busy?
Assuming that the IDE and debugger commands are on another thread, the host application can discover and cancel or override IDE command events as shown in code below.
Of course, you'll have to managed your multiple IDE threads, but you must be doing some of that already
>>2) Could we make the other IDEs busy when the main thread turns busy so that user operations on them are prevented?
See answer #1. Since the host app can manage all IDE commands, it seems that controlling/overriding/preventing all user interaction with IDE is possible.
And, it is simple to hide other IDE window(s) when one IDE is debugging
private void EnsureIDE()
{
try
{
if (this.dte == null)
{
IDTEProvider dteProvider = (IDTEProvider)new VSTADTEProviderClass();
this.dte = (EnvDTE.DTE)dteProvider.GetDTE("ShapeAppCSharp", 0);
//. . code removed for brevity and clarity. . . . //
//Before executing command with Guid={5EFC7975-14BC-11CF-9B2B-00AA00573819} and ID=295 named Debug.Start
this.commandEventsBeforeDebugStart = this.dte.Events.get_CommandEvents("{5EFC7975-14BC-11CF-9B2B-00AA00573819}", 295);
this.commandEventsBeforeDebugStart.BeforeExecute += new EnvDTE._dispCommandEvents_BeforeExecuteEventHandler(BeforeDebugStart);
this.commandEvents = this.dte.Events.get_CommandEvents("", 0);
this.commandEvents.BeforeExecute += new EnvDTE._dispCommandEvents_BeforeExecuteEventHandler(commandEvents_BeforeExecute);
}
}
catch (Exception ex)
{
System.Diagnostics.Trace.WriteLine(ex.ToString());
System.Diagnostics.Debug.Assert(false);
this.Disconnect();
}
}
void commandEvents_BeforeExecute(string Guid, int ID, object CustomIn, object CustomOut, ref bool CancelDefault)
{
EnvDTE.Command command;
string commandName;
command = this.dte.Commands.Item(Guid, ID);
if (command != null)
{
commandName = command.Name;
if (commandName == "")
{
commandName = "<unnamed>";
}
System.Windows.Forms.MessageBox.Show("Before executing command with Guid=" + Guid + " and ID=" + ID + " named " + commandName);
}
}
private void BeforeDebugStart(string Guid, int ID, object CustomIn, object CustomOut, ref bool CancelDefault)
{
CancelDefault = false; //Starts debugging
if (!this.isDebugging)
{
//Do not Start debugging
CancelDefault = true;
}
}
private EnvDTE.CommandEvents commandEvents;
private EnvDTE.CommandEvents commandEventsBeforeDebugStart;
Posted
Jun 03 2009, 09:14 AM
by
BillL