public Task Initialize(TaskScheduler scheduler) { if (this._initializationTask == null) { this._initializationTask = Task.Run(() => Core()); if (this.AutoRestart && scheduler != null) { this._initializationTask.ContinueWith( _ => this.ComObjects.Listen(), CancellationToken.None, TaskContinuationOptions.OnlyOnRanToCompletion, scheduler); } } return(this._initializationTask); void Core() { var assemblyProvider = new ComInterfaceAssemblyProvider(this.ComInterfaceAssemblyPath); var assembly = new ComInterfaceAssembly(assemblyProvider.GetAssembly()); this.ComObjects = new ComObjects(assembly); } }
static VirtualDesktop() { try { ComObjects.Initialize(); ComObjects.RegisterListener(); } catch (Exception ex) { InitializationException = ex; } AppDomain.CurrentDomain.ProcessExit += (sender, args) => ComObjects.Terminate(); }
static VirtualDesktop() { if (!IsSupported) { return; } try { ComObjects.Initialize(); } catch (Exception ex) { InitializationException = ex; _isSupportedInternal = false; } AppDomain.CurrentDomain.ProcessExit += (sender, args) => ComObjects.Terminate(); }
private VirtualDesktop(IVirtualDesktop comObject) { ComObjects.Register(comObject); this.Id = comObject.GetID(); }
static DesktopManager() { ComObjects.Initialize(); }