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);
            }
        }
예제 #2
0
        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();
        }
예제 #4
0
 private VirtualDesktop(IVirtualDesktop comObject)
 {
     ComObjects.Register(comObject);
     this.Id = comObject.GetID();
 }
예제 #5
0
 static DesktopManager()
 {
     ComObjects.Initialize();
 }