void TestThread(object objArg) { System.Threading.Thread.Sleep(1000); ThreadArg tArg = objArg as ThreadArg; int projectsLoaded = 0; int projectCount = 4; int index = 1; using (var progress = tArg.ProgressMonitor) { while (projectsLoaded < projectCount) { ////progress.TaskName = "Loading " + index; using (IProgressMonitor progressMonitor = progress.CreateSubTask(1.0 / projectCount)) { progressMonitor.TaskName = "SubTask" + index; for (int i = 1; i <= 5; i++) { progressMonitor.Progress = i * 0.2; progressMonitor.TaskName = string.Format("SubTask{0}--{1:P0}", index, progressMonitor.Progress); System.Threading.Thread.Sleep(1000); } //System.Threading.Thread.Sleep(2500); } index++; projectsLoaded++; progress.Progress = (double)projectsLoaded / projectCount; } progress.TaskName = "加载完成!"; } }
public void TestConsumerReceiveBeforeMessageDispatched(AcknowledgementMode ackMode) { // Launch a thread to perform a delayed send. Thread sendThread = new Thread(DelayedProducerThreadProc); using (IConnection connection = CreateConnection(TEST_CLIENT_ID)) { connection.Start(); using (ISession session = connection.CreateSession(ackMode)) { ITemporaryQueue queue = session.CreateTemporaryQueue(); using (IMessageConsumer consumer = session.CreateConsumer(queue)) { ThreadArg arg = new ThreadArg(); arg.connection = connection; arg.session = session; arg.destination = queue; sendThread.Start(arg); IMessage message = consumer.Receive(TimeSpan.FromMinutes(1)); Assert.IsNotNull(message); } } } }
//[Test] public virtual void TestConsumerReceiveBeforeMessageDispatched( string testDestRef, //[Values(AcknowledgementMode.AutoAcknowledge, AcknowledgementMode.ClientAcknowledge, // AcknowledgementMode.DupsOkAcknowledge, AcknowledgementMode.Transactional)] AcknowledgementMode ackMode) { // Launch a thread to perform a delayed send. Thread sendThread = new Thread(DelayedProducerThreadProc); using (IConnection connection = CreateConnection()) { connection.Start(); using (ISession session = connection.CreateSession(ackMode)) { IDestination destination = GetClearDestinationByNodeReference(session, testDestRef); using (IMessageConsumer consumer = session.CreateConsumer(destination)) { ThreadArg arg = new ThreadArg(); arg.connection = connection; arg.session = session; arg.destination = destination; sendThread.Start(arg); IMessage message = consumer.Receive(TimeSpan.FromMinutes(1)); Assert.IsNotNull(message); } } } }
/// <summary> /// 当前调用线程中执行任务处理。 /// </summary> public void StartTask() { var progressDlg = AsynchronousWaitDialog.ShowWaitDialog("已开启长时间耗时处理,请耐心等待..."); ThreadArg tArg = new ThreadArg(progressDlg); TestThread(tArg); }
//循环查询周围台站 void queryDialog_OnSelectList(List <FreqPlanActivity> obj) { busyIndicator.IsBusy = true; ThreadArg arg = new ThreadArg(); arg.FreqActivitys = obj; arg.OldRoundStations = StationItemsSource; arg.SynchContext = System.Threading.SynchronizationContext.Current; arg.OnNotifyRoundStations += p => { busyIndicator.IsBusy = false; //更新数据源 StationItemsSource = p; //绘制台站 if (OnDrawStationToMap != null && StationItemsSource != null) { List <StationInfo> stationlist = new List <StationInfo>(); for (int i = 0; i < StationItemsSource.Count; i++) { stationlist.Add(StationItemsSource[i]); } OnDrawStationToMap(stationlist); } }; Thread thread = new Thread(ThreadExec); thread.IsBackground = true; thread.Start(arg); }
private void ThreadExec(object pArg) { ThreadArg arg = pArg as ThreadArg; List <RoundStationInfo> roundStats = GetRemoteRoundStations(arg.FreqActivitys, arg.OldRoundStations); arg.ReturnStationList(roundStats); }
private void btnStartLongTimeAction_Click(object sender, EventArgs e) { var progressDlg = AsynchronousWaitDialog.ShowWaitDialog("已开启长时间耗时处理,请耐心等待..."); ThreadArg tArg = new ThreadArg(progressDlg); TestThread(tArg); }
/// <summary> /// 后台线程执行任务处理。 /// </summary> public void StartTaskByThread() { AsynchronousWaitDialog.ShowWaitDialogForAsyncOperation("已开启线程处理,请耐心等待...", progressMonitor => { ThreadArg tArg = new ThreadArg(progressMonitor); Task task = new Task(TestThread, tArg); task.Start(); }); }
private void btnStartThread_Click(object sender, EventArgs e) { AsynchronousWaitDialog.ShowWaitDialogForAsyncOperation("已开启线程处理,请耐心等待...", progressMonitor => { ThreadArg tArg = new ThreadArg(progressMonitor); Task task = new Task(TestThread, tArg); task.Start(); }); }
protected void DelayedProducerThreadProc(Object arg) { try { ThreadArg args = arg as ThreadArg; using (ISession session = args.connection.CreateSession()) { using (IMessageProducer producer = session.CreateProducer(args.destination)) { // Give the consumer time to enter the receive. Thread.Sleep(5000); producer.Send(args.session.CreateTextMessage("Hello World")); } } } catch (Exception e) { // Some other exception occurred. Assert.Fail("Test failed with exception: " + e.Message); } }
private void OnCutClicked() { var demos = _app.SelectedDemos; if(demos == null) { _app.LogError("No demo was selected. Please select at least one to proceed."); return; } _app.SaveBothConfigs(); var config = _app.Config; if(config.PatternsSelectionBitMask == 0) { _app.LogError("You didn't check any pattern. Please check at least one to proceed."); return; } var privateConfig = _app.PrivateConfig; if(privateConfig.PatternCutPlayerIndex == int.MinValue && string.IsNullOrEmpty(privateConfig.PatternCutPlayerName)) { _app.LogWarning("The selected player name is empty. Please specify a player name or select a different matching method to proceed."); } _app.DisableUiNonThreadSafe(); _app.JoinJobThread(); var filePaths = new List<string>(); foreach(var demo in demos) { filePaths.Add(demo.FilePath); } var selectedPatterns = (UInt32)config.PatternsSelectionBitMask; var patterns = new List<UDT_DLL.udtPatternInfo>(); var resources = new UDT_DLL.ArgumentResources(); if(IsPatternActive(selectedPatterns, UDT_DLL.udtPatternType.GlobalChat)) { var pattern = new UDT_DLL.udtPatternInfo(); UDT_DLL.CreateChatPatternInfo(ref pattern, resources, config.ChatRules); patterns.Add(pattern); } if(IsPatternActive(selectedPatterns, UDT_DLL.udtPatternType.FragSequences)) { var pattern = new UDT_DLL.udtPatternInfo(); var rules = UDT_DLL.CreateCutByFragArg(config, _app.PrivateConfig); UDT_DLL.CreateFragPatternInfo(ref pattern, resources, rules); patterns.Add(pattern); } if(IsPatternActive(selectedPatterns, UDT_DLL.udtPatternType.MidAirFrags)) { var pattern = new UDT_DLL.udtPatternInfo(); var rules = UDT_DLL.CreateCutByMidAirArg(config); UDT_DLL.CreateMidAirPatternInfo(ref pattern, resources, rules); patterns.Add(pattern); } if(IsPatternActive(selectedPatterns, UDT_DLL.udtPatternType.MultiFragRails)) { var pattern = new UDT_DLL.udtPatternInfo(); var rules = UDT_DLL.CreateCutByMultiRailArg(config); UDT_DLL.CreateMultiRailPatternInfo(ref pattern, resources, rules); patterns.Add(pattern); } if(IsPatternActive(selectedPatterns, UDT_DLL.udtPatternType.FlagCaptures)) { var pattern = new UDT_DLL.udtPatternInfo(); var rules = UDT_DLL.CreateCutByFlagCaptureArg(config); UDT_DLL.CreateFlagCapturePatternInfo(ref pattern, resources, rules); patterns.Add(pattern); } if(IsPatternActive(selectedPatterns, UDT_DLL.udtPatternType.FlickRails)) { var pattern = new UDT_DLL.udtPatternInfo(); var rules = UDT_DLL.CreateCutByFlickRailArg(config); UDT_DLL.CreateFlickRailPatternInfo(ref pattern, resources, rules); patterns.Add(pattern); } var threadArg = new ThreadArg(); threadArg.FilePaths = filePaths; threadArg.Patterns = patterns.ToArray(); threadArg.Resources = resources; _app.StartJobThread(DemoCutThread, threadArg); }
public void TestConsumerReceiveBeforeMessageDispatched( [Values(AcknowledgementMode.AutoAcknowledge, AcknowledgementMode.ClientAcknowledge, AcknowledgementMode.DupsOkAcknowledge, AcknowledgementMode.Transactional)] AcknowledgementMode ackMode) { // Launch a thread to perform a delayed send. Thread sendThread = new Thread(DelayedProducerThreadProc); using(IConnection connection = CreateConnection()) { connection.Start(); using(ISession session = connection.CreateSession(ackMode)) { ITemporaryQueue queue = session.CreateTemporaryQueue(); using(IMessageConsumer consumer = session.CreateConsumer(queue)) { ThreadArg arg = new ThreadArg(); arg.connection = connection; arg.session = session; arg.destination = queue; sendThread.Start(arg); IMessage message = consumer.Receive(TimeSpan.FromMinutes(1)); Assert.IsNotNull(message); } } } }
static private void DoAction(PatternAction action, uint selectedPatterns, bool saveConfigs) { var app = App.Instance; var demos = app.SelectedWriteDemos; if (demos == null) { return; } if (selectedPatterns == 0) { app.LogError("You didn't check any pattern. Please check at least one to proceed."); return; } if (saveConfigs) { app.SaveBothConfigs(); } var privateConfig = app.PrivateConfig; if (privateConfig.PatternCutPlayerIndex == int.MinValue && string.IsNullOrEmpty(privateConfig.PatternCutPlayerName)) { app.LogError("The selected player name is empty. Please specify a player name or select a different matching method to proceed."); return; } var filePaths = new List <string>(); foreach (var demo in demos) { filePaths.Add(demo.FilePath); } var config = app.Config; var patterns = new List <UDT_DLL.udtPatternInfo>(); var resources = new ArgumentResources(); if (IsPatternActive(selectedPatterns, UDT_DLL.udtPatternType.Chat)) { if (config.ChatRules.Count == 0) { app.LogError("[chat] No chat matching rule defined. Please add at least one to proceed."); return; } var pattern = new UDT_DLL.udtPatternInfo(); UDT_DLL.CreateChatPatternInfo(ref pattern, resources, config.ChatRules); patterns.Add(pattern); } if (IsPatternActive(selectedPatterns, UDT_DLL.udtPatternType.FragSequences)) { if (privateConfig.FragCutAllowedMeansOfDeaths == 0) { app.LogError("[frag sequence] You didn't check any Mean of Death. Please check at least one to proceed."); return; } if (config.FragCutMinFragCount < 2) { app.LogError("[frag sequence] 'Min. Frag Count' must be 2 or higher."); return; } if (config.FragCutTimeBetweenFrags < 1) { app.LogError("[frag sequence] 'Time Between Frags' must be strictly positive."); return; } var pattern = new UDT_DLL.udtPatternInfo(); var rules = UDT_DLL.CreateCutByFragArg(config, app.PrivateConfig); UDT_DLL.CreateFragPatternInfo(ref pattern, resources, rules); patterns.Add(pattern); } if (IsPatternActive(selectedPatterns, UDT_DLL.udtPatternType.MidAirFrags)) { if (!config.MidAirCutAllowRocket && !config.MidAirCutAllowBFG) { app.LogError("[mid-air frags] You didn't check any weapon. Please check at least one to proceed."); return; } var pattern = new UDT_DLL.udtPatternInfo(); var rules = UDT_DLL.CreateCutByMidAirArg(config); UDT_DLL.CreateMidAirPatternInfo(ref pattern, resources, rules); patterns.Add(pattern); } if (IsPatternActive(selectedPatterns, UDT_DLL.udtPatternType.MultiFragRails)) { var pattern = new UDT_DLL.udtPatternInfo(); var rules = UDT_DLL.CreateCutByMultiRailArg(config); UDT_DLL.CreateMultiRailPatternInfo(ref pattern, resources, rules); patterns.Add(pattern); } if (IsPatternActive(selectedPatterns, UDT_DLL.udtPatternType.FlagCaptures)) { if (!config.FlagCaptureAllowBaseToBase && !config.FlagCaptureAllowMissingToBase) { app.LogError("[flag captures] You disabled both base and non-base pick-ups. Please enable at least one of them to proceed."); return; } var pattern = new UDT_DLL.udtPatternInfo(); var rules = UDT_DLL.CreateCutByFlagCaptureArg(config); UDT_DLL.CreateFlagCapturePatternInfo(ref pattern, resources, rules); patterns.Add(pattern); } if (IsPatternActive(selectedPatterns, UDT_DLL.udtPatternType.FlickRails)) { if (config.FlickRailMinSpeed <= 0.0f && config.FlickRailMinAngleDelta <= 0.0f) { app.LogError("[flick rails] Both thresholds are negative or zero, which will match all railgun frags."); return; } var pattern = new UDT_DLL.udtPatternInfo(); var rules = UDT_DLL.CreateCutByFlickRailArg(config); UDT_DLL.CreateFlickRailPatternInfo(ref pattern, resources, rules); patterns.Add(pattern); } if (IsPatternActive(selectedPatterns, UDT_DLL.udtPatternType.Matches)) { var pattern = new UDT_DLL.udtPatternInfo(); var rules = UDT_DLL.CreateCutByMatchArg(config); UDT_DLL.CreateMatchPatternInfo(ref pattern, resources, rules); patterns.Add(pattern); } var threadArg = new ThreadArg(); threadArg.Demos = demos; threadArg.FilePaths = filePaths; threadArg.Patterns = patterns.ToArray(); threadArg.Resources = resources; app.DisableUiNonThreadSafe(); app.JoinJobThread(); switch (action) { case PatternAction.Cut: app.StartJobThread(DemoCutThread, threadArg); break; case PatternAction.Search: app.StartJobThread(DemoSearchThread, threadArg); break; default: break; } }