public void Dispose() { if (_consumer != null) { _consumer.Dispose(); _consumer = null; } }
static void Main(string[] args) { Console.Title = "Worker Selenium"; Bus = RabbitHutch.CreateBus(GetBusConfiguration(FindRabbit())); Logger = new LoggerConfiguration() .WriteTo.ColoredConsole() .WriteTo.RollingFile("log.txt", retainedFileCountLimit: 7) .CreateLogger(); var dir = AppDomain.CurrentDomain.BaseDirectory; dir = Path.GetFullPath(Path.Combine(dir, @"..\..\..\")); var chromePortable = Path.Combine(dir, @"GoogleChromePortable\GoogleChromePortable.exe"); IWebDriver driver = new ChromeDriver(new ChromeOptions { BinaryLocation = chromePortable }); IJavaScriptExecutor jse = (IJavaScriptExecutor)driver; SubscriptionResult = Bus.SubscribeAsync("subscriptionId", GetLogic(node => Logger.Information("{@Node}", node), url => { driver.Navigate().GoToUrl(url); driver.WaitForPageLoad(); return(Task.FromResult(true)); }, script => { string result = (string)jse.ExecuteScript(script.Replace("(function() {", "").Replace("})();", "")); return(Task.FromResult(result)); }, async node => await Bus.PublishAsync(node), async node => await Bus.PublishAsync(new Result { Node = node }), async node => { Logger.Error("{@Node}", node); await Bus.PublishAsync(new ErrorResult { Node = node }); }, node => { })); Console.ReadLine(); SubscriptionResult.Dispose(); driver.QuitAll(); Environment.Exit(0); }
public MainWindow() { Title = "Worker CefSharp WPF"; InitializeComponent(); Bus = RabbitHutch.CreateBus(GetBusConfiguration(FindRabbit())); Logger = new LoggerConfiguration() .WriteTo.RollingFile("log.txt", retainedFileCountLimit: 7) .CreateLogger(); InitializeChromium(); Loaded += MainWindow_Loaded; Closed += (sender, args) => { SubscriptionResult.Dispose(); }; }
public static void Main(string[] args) { Console.Title = "Worker CefSharp OffScreen"; Bus = RabbitHutch.CreateBus(GetBusConfiguration(FindRabbit())); Logger = new LoggerConfiguration() .WriteTo.ColoredConsole() .WriteTo.RollingFile("log.txt", retainedFileCountLimit: 7) .CreateLogger(); InitializeChromium(); SubscriptionResult = Bus.SubscribeAsync("subscriptionId", GetLogic(node => Logger.Information("{@Node}", node), url => Task.FromResult(Browser.LoadPage(url)), script => Task.FromResult(Browser.EvaluateScriptWithReturn(script)), async node => await Bus.PublishAsync(node), async node => await Bus.PublishAsync(new Result { Node = node }), async node => { Logger.Error("{@Node}", node); await Bus.PublishAsync(new ErrorResult { Node = node }); }, node => {})); Console.ReadLine(); SubscriptionResult.Dispose(); // Clean up Chromium objects. You need to call this in your application otherwise // you will get a crash when closing. Cef.Shutdown(); Environment.Exit(0); }
public MainForm() { InitializeComponent(); Text = "Worker CefSharp WinForms"; Bus = RabbitHutch.CreateBus(GetBusConfiguration(FindRabbit())); Logger = new LoggerConfiguration() .WriteTo.RollingFile("log.txt", retainedFileCountLimit: 7) .CreateLogger(); InitializeChromium(); Load += MainForm_Loaded; FormClosed += (sender, args) => { SubscriptionResult.Dispose(); Cef.Shutdown(); Environment.Exit(0); }; }
public void Dispose() { subscription.Dispose(); }
public void DisposeQueueProductMail() { _currentSubscription.Dispose(); }
public void Stop() { // disposing the subscription result stops our subscription and we do not accept new messages subscriptionResult?.Dispose(); }
public void Dispose() { _token.Dispose(); _module.Unsubscribe(this, _id); }
static void Main(string[] args) { Console.Title = "Worker Remote Debugging"; var dir = AppDomain.CurrentDomain.BaseDirectory; dir = Path.GetFullPath(Path.Combine(dir, @"..\..\..\")); Process.Start(Path.Combine(dir, @"GoogleChromePortable\GoogleChromePortable.exe"), "--remote-debugging-port=9222 about:blank"); while (!UrlExists("http://*****:*****@Node}", node), url => { using (MyClientWebSocket ws = new MyClientWebSocket(firstUrl)) { ws.Open(url, CancellationToken.None); ws.WaitForDocumentReady(); return(Task.FromResult(true)); } }, script => { using (MyClientWebSocket ws = new MyClientWebSocket(firstUrl)) { string value = ws.EvaluateWithReturn(script, CancellationToken.None); ws.WaitForDocumentReady(); return(Task.FromResult(value)); } }, async node => await Bus.PublishAsync(node), async node => await Bus.PublishAsync(new Result { Node = node }), async node => { Logger.Error("{@Node}", node); await Bus.PublishAsync(new ErrorResult { Node = node }); }, node => { })); //Test(firstUrl); Console.ReadLine(); SubscriptionResult.Dispose(); var chromePoratable = Process.GetProcessesByName("GoogleChromePortable"); chromePoratable.ToList().ForEach(x => IgnoreExceptions(() => x.Kill())); Environment.Exit(0); }