public void Run() { //Start thread for UI var thread = new Thread(ThreadStart); thread.TrySetApartmentState(ApartmentState.STA); thread.Start(); CreatePlayers(); //Sets players in current game GenerateCurrPlayers(); //врътка players GenerateCyclePlayers(); dealer.FillDeck(database, cardFactory); dealer.Shuffle(database.Deck); dealer.DealCards(database.Deck, database.HumanPlayers, database.BotPlayers, database.TableCards); //Sets players power depending on their cards combinations SetPlayersPower(); AddBlindsToPot(); }
private static void myScreenshot() { var thread = new Thread(ThreadStart); // allow UI with ApartmentState.STA though [STAThread] above should give that to you thread.TrySetApartmentState(ApartmentState.STA); thread.Start(); }
static void Main() { // Application.EnableVisualStyles(); //Application.SetCompatibleTextRenderingDefault(false); //try //{ Game game = new Game(); GameForm gf; gf = new GameForm(game); Thread t = new Thread(new ParameterizedThreadStart(game.Start)); t.Name = "GameLoop"; t.IsBackground = true; t.TrySetApartmentState(ApartmentState.STA); t.Start(gf); //Thread tt = new Thread(new ThreadStart(gf.Show2)); //tt.Start(); gf.Init(); //} //catch (Exception e) { MessageBox.Show(e.Message + e.InnerException + e.Source + e.StackTrace); } //if (t.ThreadState == ThreadState.Running) // t.Abort(); //Application.Run(new GameForm()); }
protected VisualizatorDomainAppl() { _thread = new Thread(WorkThread); if (!_thread.TrySetApartmentState(ApartmentState.STA)) throw new Exception("Не удалось установить STA ApartmentState"); _main = new InvisibleMainForm(this); }
public NetStateController() { recv = new NetStreamMultiReceiver(RTSConstants.MC_ADDR, RTSConstants.MC_GAME_PORT_MIN); tNet = new Thread(NetThread); tNet.Priority = ThreadPriority.BelowNormal; tNet.TrySetApartmentState(ApartmentState.MTA); tNet.IsBackground = true; }
public MessageLoop() { thread = new Thread(threadLoop); thread.TrySetApartmentState(ApartmentState.STA); threadStarted = new TaskCompletionSource<bool>(); thread.Start(); threadStarted.Task.Wait(); }
// create package private void button3_Click(object sender, EventArgs e) { if (comboBox1.SelectedItem != null) { StartProcessing(); thr = new Thread(new ParameterizedThreadStart(ProcessPackage)); thr.TrySetApartmentState(ApartmentState.STA); // this fixes saveFileDialog exception thr.Start(comboBox1.SelectedItem); } }
public void clientListUpdated(long count) { if (controller == null) controller = ChatController.getController(); Console.WriteLine("* New client list is ready, event is: " + count); Thread t = new Thread(() => controller.updateClientList(count)); t.TrySetApartmentState(ApartmentState.STA); t.Start(); }
public Plotter(string title, params Series[] s) { //new Plotter("Train", new FunctionSeries(Math.Cos, 0, 10, 0.1, "cos(x)")) Title = title; Series = s; InitializeComponent(); var thread = new Thread(() => Application.Run(this)); thread.TrySetApartmentState(ApartmentState.STA); thread.Start(); }
static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); var thread = new Thread(ThreadStart); // allow UI with ApartmentState.STA though [STAThread] above should give that to you thread.TrySetApartmentState(ApartmentState.STA); thread.Start(); Application.Run(new GateIn()); }
private void StartListenerThread() { Trace.WriteLine("++WorkerRole.StartListenerThread", "Information"); _listenerThread = null; _listenerThread = new Thread(TCPListener.TcpListenerProcess); _listenerThread.TrySetApartmentState(ApartmentState.STA); _listenerThread.Name = "Server TCP Listener"; _listenerThread.Start(); Trace.WriteLine("--WorkerRole.StartListenerThread", "Information"); }
/// <summary> /// Open the 3D visualization in a exclusive thread in order to it do not create /// a conflict with the application thread /// </summary> public static void Start() { // If there is already a thread, kill it if (_thread != null && _thread.IsAlive) { _thread.Abort(); } // Start a new thread calling startMethod method _thread = new Thread(StartMethod); _thread.TrySetApartmentState(ApartmentState.MTA); _thread.Start(); IsActive = true; }
/// <summary> /// 通过线程每隔一点时间刷数据库,保持连接 /// </summary> public static void KeepConntion() { _thread = new Thread(LoopDual); _thread.Name = "KeepOracleConnection"; _thread.IsBackground = true; // 设置线程状态为单线程 try { _thread.TrySetApartmentState(ApartmentState.STA); } catch (Exception ex) { Logging.Write("KeepConntion 启动失败,线程设置出现错误,原因是:" + ex.ToString()); return; } _thread.Start(); }
static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); PXCMSession session = null; pxcmStatus sts = PXCMSession.CreateInstance(out session); if (sts >= pxcmStatus.PXCM_STATUS_NO_ERROR) { var thread = new Thread(ThreadStart); // allow UI with ApartmentState.STA though [STAThread] above should give that to you thread.TrySetApartmentState(ApartmentState.STA); thread.Start(); Application.Run(new MainForm(session)); session.Dispose(); } }
//constructor public Loop(Main window, int targetUps, Boolean fpsLock, int maxFps) { //Console.WriteLine(window.GPanel.Visible); //stelt alle variablen in this.window = window; //window.GPanel. window.Paint += this.render; this.targetUps = targetUps; this.fpsLock = fpsLock; this.maxFps = maxFps; //intalizeerd het spel game = new Game(this); //initalizeerd de gameloop thraed en start hem op de methode init(); t = new Thread(init); t.Priority = ThreadPriority.Highest; t.TrySetApartmentState(ApartmentState.MTA); t.Start(); }
public void RunTest() { GetPreviousResults(); var directoryInfo = new DirectoryInfo(WorkingDirectory + _outputFolder); directoryInfo.Create(); var wcatServer = new WcatServer(WorkingDirectory, _testName, WarmUpTime, Duration, CoolDownTime, _outputFolder, _server, _serverName); var wcatServerThread = new Thread(wcatServer.Start); wcatServerThread.TrySetApartmentState(ApartmentState.MTA); var wcatClient = new WcatClient(WorkingDirectory); var wcatClientThread = new Thread(wcatClient.Start); wcatClientThread.TrySetApartmentState(ApartmentState.MTA); //wcatServerThread.IsBackground = true; //wcatClientThread.IsBackground = true; wcatServerThread.Start(); Thread.Sleep(2000);//wait for server to start wcatClientThread.Start(); Thread.Sleep(2000);//wait for client to start while (wcatServerThread.ThreadState != ThreadState.Stopped) { //Thread.Sleep(1000); } Assert.IsTrue(File.Exists(WorkingDirectory + _outputFolder + "\\log.log")); LoggingHelper.WriteFileSection("RUN LOG FILE", WorkingDirectory + _outputFolder + "\\log.log"); Assert.IsTrue(File.Exists(WorkingDirectory + _outputFolder + "\\log.xml")); LoggingHelper.WriteFileSection("RUN XML LOG FILE", WorkingDirectory + _outputFolder + "\\log.xml"); _xmlResults = new XmlDocument(); _xmlResults.Load(WorkingDirectory + _outputFolder + "\\log.xml"); Assert.IsTrue(File.Exists(WorkingDirectory + _outputFolder + "\\log.prf")); LoggingHelper.WriteFileSection("RUN PERFMON LOG FILE", WorkingDirectory + _outputFolder + "\\log.prf"); if (_prevXmlResults == null) { Assert.Inconclusive("Unable to find previous run"); } }
public static void Export(DataTable data, string name) { SaveFileDialog dialog = new SaveFileDialog(); dialog.Title = "Export " + name + " data to csv"; dialog.Filter = "csv files (*.csv)|*.csv"; dialog.AddExtension = true; dialog.DefaultExt = ".csv"; dialog.OverwritePrompt = true; dialog.InitialDirectory = UserAccount.Settings.CSVExportDir; DialogResult result = dialog.ShowDialog(); if (result == DialogResult.OK) { _filename = dialog.FileName; CSVExport expObj = new CSVExport(); Thread t1 = new Thread(new ParameterizedThreadStart(expObj.DoExport)); t1.TrySetApartmentState(ApartmentState.STA); ProgressDialog prgDialog = new ProgressDialog("Building " + name + " CSV file...", expObj); t1.Start(data); prgDialog.ShowDialog(); } }
/// <summary> /// starts thread execution /// </summary> public void Start() { ThreadObject = new Thread(new ThreadStart(StartTarget)) { Name = this.Name }; if (_aptState != null) { ThreadObject.TrySetApartmentState((ApartmentState) _aptState); } ThreadObject.Start(); }
public static void startScanDB() { if (_thread == null || !_thread.IsAlive) { _thread = new Thread(GoGo); _thread.Name = "Schduler"; _thread.IsBackground = true; // 设置线程状态为单线程 try { _thread.TrySetApartmentState(ApartmentState.STA); } catch (Exception ex) { Logging.Write("启动失败,线程设置出现错误,原因是:" + ex.ToString()); return; } _thread.Start(); Logging.Write("计划开始运行。。。。。"); SpyDB.WriteLog("计划任务", "开始运行"); } }
public static void StartFB() { BarMapper.MapBars(); KeyHelper.LoadKeys(); if (_Thread == null || !_Thread.IsAlive) { _Thread = new Thread(gogo); _Thread.Name = "FB"; _Thread.IsBackground = true; // 设置线程状态为单线程 try { _Thread.TrySetApartmentState(ApartmentState.STA); } catch (Exception ex) { Logging.Write("启动失败,线程设置出现错误,原因是:" + ex.ToString()); return; } _Thread.Start(); Logging.Write("开始了。。。。。"); } }
public static void start() { if (_AutoLogin == null || !_AutoLogin.IsAlive) { _AutoLogin = new Thread(gogo); _AutoLogin.Name = "AutoLoginWOW"; _AutoLogin.IsBackground = true; // 设置线程状态为单线程 try { _AutoLogin.TrySetApartmentState(ApartmentState.STA); } catch (Exception ex) { Logging.Write("启动失败,线程设置出现错误,原因是:" + ex.ToString()); return; } _AutoLogin.Start(); Logging.Write("AutoLoginWOW开始了。。。。。"); } }
public static void start() { if (Items == null || Items.Columns.Count == 0) { Logging.Write("没有设置拍卖列表"); return; } if (_thread == null || !_thread.IsAlive) { _thread = new Thread(gogo); _thread.Name = "AutoAH"; _thread.IsBackground = true; // 设置线程状态为单线程 try { _thread.TrySetApartmentState(ApartmentState.STA); } catch (Exception ex) { Logging.Write("启动失败,线程设置出现错误,原因是:" + ex.ToString()); return; } _thread.Start(); Logging.Write("自动拍卖开始了。。。。。"); } }
public static void start() { if (_thread == null || !_thread.IsAlive) { _thread = new Thread(GoGo); _thread.Name = "分解矿"; _thread.IsBackground = true; // 设置线程状态为单线程 try { _thread.TrySetApartmentState(ApartmentState.STA); } catch (Exception ex) { Logging.Write("启动失败,线程设置出现错误,原因是:" + ex.ToString()); RUNNING = false; return; } _thread.Start(); Logging.Write("分解矿 开始了。。。。。"); } }
public void TestTrySetApartmentStateRunning () { Thread t1 = new Thread (new ThreadStart (Start)); t1.SetApartmentState (ApartmentState.STA); Assert.AreEqual (ApartmentState.STA, t1.ApartmentState, "#1"); t1.Start (); try { t1.TrySetApartmentState (ApartmentState.STA); Assert.Fail ("#2"); } catch (ThreadStateException) { } t1.Join (); }
public void TestTrySetApartmentState () { Thread t1 = new Thread (new ThreadStart (Start)); t1.SetApartmentState (ApartmentState.STA); Assert.AreEqual (ApartmentState.STA, t1.ApartmentState, "#1"); bool result = t1.TrySetApartmentState (ApartmentState.MTA); Assert.IsFalse (result, "#2"); result = t1.TrySetApartmentState (ApartmentState.STA); Assert.IsTrue (result, "#3"); }
public bool TrySetApartmentState(ApartmentState state) { return(_Thread.TrySetApartmentState(state)); }
/// <summary> /// Normal text /// </summary> /// <param name="text"></param> private void NormalText(string text) { if (String.IsNullOrWhiteSpace(text)) { return; } Object styleTitle = WdBuiltinStyle.wdStyleNormalObject; Object styleTitle2 = WdBuiltinStyle.wdStyleHtmlNormal; var doc = Application.ActiveDocument; var pt = OfficeHelper.CreateParagraphRange(ref doc); pt.Text = text; pt.set_Style(ref styleTitle2); var thread = new Thread(SetClipboard); if (thread.TrySetApartmentState(ApartmentState.STA)) { thread.Start(text); thread.Join(); } try { object objDataTypeMetafile = WdPasteDataType.wdPasteHTML; pt.PasteSpecial(DataType: objDataTypeMetafile); if (Application.ActiveDocument.InlineShapes.Count > 0) { var page = Application.ActiveDocument.PageSetup; float calculatedWidth = page.PageWidth - (page.LeftMargin + page.RightMargin); foreach (InlineShape shape in Application.ActiveDocument.InlineShapes) { shape.LockAspectRatio = MsoTriState.msoTrue; if (shape.Width <= calculatedWidth) continue; shape.Width = calculatedWidth; } } } catch (Exception) { } Application.ActiveDocument.Content.InsertParagraphAfter(); }
private void _createUpdateClientThread() { Thread t = new Thread(informClientsListChanged); t.TrySetApartmentState(ApartmentState.STA); t.Start(); }
/// <summary> /// Start video source. /// </summary> /// /// <remarks>Starts video source and return execution to caller. Video source /// object creates background thread and notifies about new frames with the /// help of <see cref="NewFrame"/> event.</remarks> /// public void Start( ) { if ( !IsRunning ) { // check source if ( string.IsNullOrEmpty( _deviceMoniker ) ) throw new ArgumentException( "Video source is not specified." ); _framesReceived = 0; _bytesReceived = 0; _isCrossbarAvailable = null; _needToSetVideoInput = true; // create events _stopEvent = new ManualResetEvent( false ); lock ( _sync ) { // create and start new thread _thread = new Thread( WorkerThread ) {Name = _deviceMoniker, IsBackground = true}; _thread.TrySetApartmentState(ApartmentState.STA); _thread.Start( ); } } }
public void ShowDialog() { Thread thread = new Thread(new ThreadStart(this._ShowMail)) { Name = "Mail msg thread", IsBackground = true }; thread.TrySetApartmentState(ApartmentState.STA); thread.Start(); this._manualResetEvent.WaitOne(); this._manualResetEvent.Reset(); }
private void CompileCodeOnStaThread(string workingPath) { Exception failed = null; bool success = false; var staThread = new Thread(() => { try { success = CompileCode(workingPath); } catch (Exception ex) { failed = ex; } }); if (staThread.TrySetApartmentState(ApartmentState.STA)) { _log.Info("Successfully set STA on compile thread"); } else { _log.Warn("STA not set on compile thread"); } staThread.Name = "Compile"; staThread.Start(); staThread.Join(); if (failed != null) { throw new ApplicationException("Compilation failed", failed); } if (!success) { throw new ApplicationException("Compilation failed"); } }