void worker_DoWork(object sender, DoWorkEventArgs e) { _initialDateTime = DateTime.Now; _manuallyStopped = false; var timelapse = new Stopwatch(); while (!_manuallyStopped) { if ((sender as BackgroundWorker).CancellationPending) { e.Cancel = true; break; } Dispatcher.BeginInvoke(new dWriteConsole(WriteConsole), System.Windows.Threading.DispatcherPriority.DataBind, string.Format("Betting {0} at {1} {2}", _currentAmount, _chance, _bet?"over":"under")); _roll = _CurrentSite.Roll(_currentAmount, _chance, _bet); if (_roll.status) { _balance = _roll.balance; parseScript(_roll); _contador++; } (sender as BackgroundWorker).ReportProgress(_contador); } }
private void parseScript(GenericRoll bet) { try { bool Win = bet.data.status.Equals("WIN"); SetLuaVars(); Lua["win"] = Win; Lua["currentprofit"] = bet.data.profit; Lua["lastBet"] = bet; LuaRuntime.SetLua(Lua); LuaRuntime.Run("dobet()"); GetLuaVars(); } catch { } }