public void MakeDefault()
{
if (Runspace.DefaultRunspace == null)
{
lock (_dispatcherLock)
{
if (Runspace.DefaultRunspace == null)
{
// Set this runspace as DefaultRunspace so I can script DTE events.
//
// WARNING: MSDN says this is unsafe. The runspace must not be shared across
// threads. I need this to be able to use ScriptBlock for DTE events. The
// ScriptBlock event handlers execute on DefaultRunspace.
Runspace.DefaultRunspace = _runspace;
}
}
}
}