コード例 #1
0
        public WebScraperDispatcher()
        {
            _currentDispatcher = Dispatcher.CurrentDispatcher;
            _currentAppDomain = AppDomain.CurrentDomain;
            _browsers = new Dictionary<string, WebScraperBrowser>();
            _appAndDispatcherSetted = new TaskCompletionSource<bool>();
            
            _mainThread = new Thread(new ParameterizedThreadStart((dispatcher) =>
                        {
                            var parentDispatcher = dispatcher as WebScraperDispatcher;
                            var threadDispatcher = WebScraperApplication.CurrentDispatcher;
                            
                            WebScraperApplication threadApp = new WebScraperApplication();

                            parentDispatcher.SetApplication(threadApp, threadDispatcher);
                            threadApp.Run();
                        }));
            _mainThread.SetApartmentState(ApartmentState.STA);
            _mainThread.Start(this);

            _appAndDispatcherSetted.Task.Wait();
        }
コード例 #2
0
 private void SetApplication(WebScraperApplication app, Dispatcher appDispatcher)
 {
     _app = app;
     _appDispatcher = appDispatcher;
     _appAndDispatcherSetted.SetResult(true);
 }