public FakeStockSchedule(bool isStockOpen, TimeSpan dueTime) { this.isStockOpen = isStockOpen; if (!isStockOpen) { var timer = new Timer((obj) => { this.isStockOpen = true; StockExchangedOpened?.Invoke(this, null); }, null, Timeout.Infinite, Timeout.Infinite); timer.Change((int)dueTime.TotalMilliseconds, Timeout.Infinite); } }
private void OnStockExchangedOpened(object state) { StockExchangedOpened?.Invoke(this, null); Thread.Sleep(1); CheckForOpeningOfStockExchange(); }