public void Run() { isCancel = false; isRun = true; bool replace; bool showNew; switch (nowTask) { case MyTask.ExportData: if (mArgs != null && mArgs.Length >= 2) { ExportData(mArgs[0], mArgs[1]); } break; case MyTask.CheckUpdate: showNew = false; if (mArgs != null && mArgs.Length >= 1) { showNew = (mArgs[0] == Boolean.TrueString) ? true : false; } OnCheckUpdate(showNew); break; case MyTask.CutImages: if (mArgs != null && mArgs.Length >= 2) { replace = true; if (mArgs.Length >= 2) { if (mArgs[1] == Boolean.FalseString) { replace = false; } } CutImages(mArgs[0], replace); } break; case MyTask.SaveAsMSE: if (mArgs != null && mArgs.Length >= 2) { replace = false; if (mArgs.Length >= 2) { if (mArgs[1] == Boolean.TrueString) { replace = true; } } SaveMSEs(mArgs[0], cardlist, replace); } break; case MyTask.ReadMSE: if (mArgs != null && mArgs.Length >= 2) { replace = false; if (mArgs.Length >= 2) { if (mArgs[1] == Boolean.TrueString) { replace = true; } } cardlist = ReadMSE(mArgs[0], replace); } break; case MyTask.ConvertImages: if (mArgs != null && mArgs.Length >= 2) { replace = true; if (mArgs.Length >= 3) { if (mArgs[2] == Boolean.FalseString) { replace = false; } } ConvertImages(mArgs[0], mArgs[1], replace); } break; } isRun = false; lastTask = nowTask; nowTask = MyTask.NONE; if (lastTask != MyTask.ReadMSE) { cardlist = null; } mArgs = null; }
public void Task_ConcurrentQueue() { MyTask.Test_ConcurrentQueue(); }
public ActionResult Edit(Guid Id) { MyTask task = dal.GetTask(Id); return(View(task)); }
public void Task_AsyncAwaitException() { MyTask.Test_AsyncAwaitException(); }
public void Task_BlockingCollection() { MyTask.Test_BlockingCollection(); }
public void Task_Interlocked() { MyTask.TestTaskInterlocked(); }
public void Task_ChildTask() { MyTask.TestChildTask(); }
public override void HandleRequest(int flag, ObservableCollection <MyTask> Tasks, MyTask selectedTask) { if (flag == 3 && selectedTask != null) { XmlSerialDeSerial x = new XmlSerialDeSerial(); x.SerializeObject(Tasks, "DbTasks"); MessageBox.Show("Saved"); return; } else if (Successor != null) { Successor.HandleRequest(flag, Tasks, selectedTask); } }
public MyDebugTaskNode(MyTask task, Action enabledCallback) : base(task) { Icon = Properties.Resources.gears; OwnerName = task.GetType().Name; m_enabledCallback = enabledCallback; }
public MyExecutionBlock CreateNodeExecutionPlan(MyWorkingNode node, bool initPhase) { List <IMyExecutable> defaultPlanContent = new List <IMyExecutable>(); if (!initPhase && PlanSignalTasks) { defaultPlanContent.Add(new MyIncomingSignalTask(node)); } foreach (string taskName in node.GetInfo().KnownTasks.Keys) { MyTask task = node.GetTaskByPropertyName(taskName); if (task != null && !task.DesignTime && (initPhase && task.OneShot || !initPhase && !task.OneShot)) { defaultPlanContent.Add(task); } } MyNodeGroup nodeGroup = node as MyNodeGroup; if (nodeGroup != null) { IEnumerable <MyNode> children = nodeGroup.Children.OrderBy(x => x.TopologicalOrder); foreach (MyNode childNode in children) { MyWorkingNode childWorkingNode = childNode as MyWorkingNode; if (childWorkingNode != null) { defaultPlanContent.Add(CreateNodeExecutionPlan(childWorkingNode, initPhase)); } } } if (!initPhase && PlanSignalTasks) { defaultPlanContent.Add(new MyOutgoingSignalTask(node)); } MyExecutionBlock defaultPlan = new MyExecutionBlock(defaultPlanContent.ToArray()); defaultPlan.Name = node.Name; MyExecutionBlock resultPlan = defaultPlan; IMyCustomExecutionPlanner executionPlannerNode = node as IMyCustomExecutionPlanner; if (executionPlannerNode != null) { if (initPhase) { resultPlan = executionPlannerNode.CreateCustomInitPhasePlan(defaultPlan); } else { resultPlan = executionPlannerNode.CreateCustomExecutionPlan(defaultPlan); } resultPlan.Name = defaultPlan.Name; } if (resultPlan.Name == null) { resultPlan.Name = node.GetType().Name; } if (node is MyNodeGroup) { resultPlan.Name += " (group)"; } // TODO(HonzaS): Rethink this. It's only used in profiling results. node.ExecutionBlock = resultPlan; return(resultPlan); }
public MyDebugTaskNode(MyTask task) : base(task) { Icon = Properties.Resources.gears; OwnerName = task.GetType().Name; }
private void buttonDivideByZeroTask_Click(object sender, EventArgs e) { MyTask testTask = new MyTask(AllTasks.DivideByZeroTask, null); threadPool.AddTaskInQueue(testTask); }
public void MarkAsModified(MyTask item) { Entry(item).State = EntityState.Modified; }
public void Post([FromBody] MyTask task) { _context.Tasks.Add(task); _context.SaveChanges(); }
//设置任务 public void SetTask(MyTask myTask, Card[] cards, params string[] args) { nowTask = myTask; cardlist = cards; mArgs = args; }
public override void HandleRequest(int flag, ObservableCollection <MyTask> Tasks, MyTask selectedTask) { if (flag == 4) { MyTask t = new MyTask(); t.Title = "New task"; Tasks.Add(t); List <MyTask> l = new List <MyTask>(); foreach (MyTask m in Tasks) { l.Add(m); } l.Reverse(); Tasks.Clear(); for (int i = 0; i < l.Count; i++) { Tasks.Add(l[i]); } XmlSerialDeSerial x = new XmlSerialDeSerial(); x.SerializeObject(Tasks, "DbTasks"); MessageBox.Show("Added"); return; } else if (Successor != null) { Successor.HandleRequest(flag, Tasks, selectedTask); } }
public MyTask Add(MyTask newTask) { context.MyTask.Add(newTask); context.SaveChanges(); return(newTask); }
public override void Run(IEnumerable <MyTask> tasks) { int maxConcurentTasks = 11 + 3; ThreadPool.SetMinThreads(maxConcurentTasks, maxConcurentTasks); ThreadPool.SetMaxThreads(maxConcurentTasks, maxConcurentTasks); int totalToProcess = 0; int toProcess = 0; int bc2Count = 0; int bc3Count = 0; BlockingCollection <MyTask> bc1 = new BlockingCollection <MyTask>(); BlockingCollection <MyTask> bc2 = new BlockingCollection <MyTask>(); BlockingCollection <MyTask> bc3 = new BlockingCollection <MyTask>(); Semaphore semaphore1 = new Semaphore(5, 5); Semaphore semaphore2 = new Semaphore(3, 3); Semaphore semaphore3 = new Semaphore(3, 3); foreach (MyTask task in tasks) { bc1.Add(task); Interlocked.Increment(ref toProcess); } totalToProcess = toProcess; bc1.CompleteAdding(); using (ManualResetEvent resetEvent = new ManualResetEvent(false)) { Task bc1Runner = Task.Run(() => { while (true) { MyTask task = bc1.Take(); semaphore1.WaitOne(); Task.Run(() => { { task.DoStepN(1); Console.WriteLine("do " + task.ID + " dostep 1...END"); bc2.Add(task); Interlocked.Increment(ref bc2Count); } semaphore1.Release(); }); } #pragma warning disable CS0162 // Unreachable code detected Console.WriteLine("bc1 complete!!!!!!"); #pragma warning restore CS0162 // Unreachable code detected }); Task bc2Runner = Task.Run(() => { while (true) { if (bc2Count == totalToProcess) { bc2.CompleteAdding(); } Console.WriteLine(bc2.Count); MyTask task = bc2.Take(); semaphore2.WaitOne(); Task.Run(() => { { task.DoStepN(2); Console.WriteLine("do " + task.ID + " dostep 2...END"); bc3.Add(task); Interlocked.Increment(ref bc3Count); } semaphore2.Release(); }); } #pragma warning disable CS0162 // Unreachable code detected Console.WriteLine("bc2 complete!!!!!!"); #pragma warning restore CS0162 // Unreachable code detected }); Task task3Runner = Task.Run(() => { while (true) { if (bc3Count == totalToProcess) { bc3.CompleteAdding(); } MyTask task = bc3.Take(); semaphore3.WaitOne(); Task.Run(() => { { task.DoStepN(3); Console.WriteLine(task.ID + " dostep 3..."); if (Interlocked.Decrement(ref toProcess) == 0) { resetEvent.Set(); } } semaphore3.Release(); }); } #pragma warning disable CS0162 // Unreachable code detected Console.WriteLine("bc3 complete!!!!!!"); #pragma warning restore CS0162 // Unreachable code detected }); resetEvent.WaitOne(); } }
public void Task_DeadLock() { MyTask.TaskDeadLock(); }
public void Task_ConcurrentDictionary() { MyTask.Test_ConcurrentDictionary(); }
public void Task_AsyncAwait() { MyTask.Test_AsyncAwait(); }
public void Task_Cancellation() { MyTask.Task_Cancellation(); }
public void Task_AsyncAwaitWhenAll() { MyTask.Test_AsyncAwaitWhenAll(); }
public void Task_OperationCanceledException() { MyTask.Task_OperationCanceledException(); }
public void Task_ConcurrentStack() { MyTask.Test_ConcurrentStack(); }
public void Task_ContinueWith() { MyTask.TestContinueWith(); }
private void gridView1_CustomColumnDisplayText(object sender, DevExpress.XtraGrid.Views.Base.CustomColumnDisplayTextEventArgs e) { if (e.Column.FieldName == "OutcomeDate") { MyTask app = gridView1.GetRow(e.RowHandle) as MyTask; if (app != null) { if (app.OutcomeDate == DateTime.MinValue) { e.DisplayText = ""; } } } else if (e.Column.FieldName == "PercentageCompleteness") { MyTask app = gridView1.GetRow(e.RowHandle) as MyTask; if (app != null) { if (app.PercentageCompleteness == 0) { e.DisplayText = ""; } } } else if (e.Column.Name == "colFiscale") { MyTask app = gridView1.GetRow(e.RowHandle) as MyTask; if (app != null) { if (app.Customer != null) { e.DisplayText = app.Customer.CodiceFiscale; } } } else if (e.Column.Name == "colContatti") { MyTask app = gridView1.GetRow(e.RowHandle) as MyTask; if (app != null) { if (app.Customer != null) { e.DisplayText = app.Customer.Residenza.ToString(); } } } else if (e.Column.Name == "colTelContatti") { MyTask app = gridView1.GetRow(e.RowHandle) as MyTask; if (app != null) { if (app.Customer != null) { e.DisplayText = app.Customer.Comunicazione.TelefonoUfficio; } } } else if (e.Column.Name == "colCell1") { MyTask app = gridView1.GetRow(e.RowHandle) as MyTask; if (app != null) { if (app.Customer != null) { e.DisplayText = app.Customer.Comunicazione.Cellulare1; } } } else if (e.Column.Name == "colCell2") { MyTask app = gridView1.GetRow(e.RowHandle) as MyTask; if (app != null) { if (app.Customer != null) { e.DisplayText = app.Customer.Comunicazione.Cellulare2; } } } }
public void Task_ThreadSafetyViolation() { MyTask.Task_ThreadSafetyViolation(); }
public void Task_ObjectLock() { MyTask.TestTaskObjectLock(); }
public void Run() { isCancel = false; isRun = true; bool replace; bool showNew; switch (nowTask) { case MyTask.ExportData: if (mArgs != null && mArgs.Length >= 2) { ExportData(mArgs[0], mArgs[1]); } break; case MyTask.CheckUpdate: showNew = false; if (mArgs != null && mArgs.Length >= 1) { showNew = (mArgs[0] == Boolean.TrueString) ? true : false; } OnCheckUpdate(showNew); break; case MyTask.CutImages: if (mArgs != null && mArgs.Length >= 2) { replace = true; if (mArgs.Length >= 2) { if (mArgs[1] == Boolean.FalseString) replace = false; } CutImages(mArgs[0], replace); } break; case MyTask.SaveAsMSE: if (mArgs != null && mArgs.Length >= 2) { replace = false; if (mArgs.Length >= 2) { if (mArgs[1] == Boolean.TrueString) replace = true; } SaveMSEs(mArgs[0], cardlist, replace); } break; case MyTask.ReadMSE: if (mArgs != null && mArgs.Length >= 2) { replace = false; if (mArgs.Length >= 2) { if (mArgs[1] == Boolean.TrueString) replace = true; } cardlist = ReadMSE(mArgs[0], replace); } break; case MyTask.ConvertImages: if (mArgs != null && mArgs.Length >= 2) { replace = true; if (mArgs.Length >= 3) { if (mArgs[2] == Boolean.FalseString) replace = false; } ConvertImages(mArgs[0], mArgs[1], replace); } break; } isRun = false; lastTask = nowTask; nowTask = MyTask.NONE; if(lastTask != MyTask.ReadMSE) cardlist = null; mArgs = null; }
public void Task_Monitor() { MyTask.TestTaskMonitor(); }
public void TakeAnswer(MyTask My7Tas_) { throw new NotImplementedException(); }
private void btTestSearchText_Click(object sender, RoutedEventArgs e) { //Dictionary<string, HashSet<uint>> d = new Dictionary<string, HashSet<uint>>(); //d.Add("t1", null); //d.Add("t2", new HashSet<uint> { 4, 5, 6 }); //var btx = Biser.Encode_DICT_PROTO_STRING_UINTHASHSET(d, Compression.eCompressionType.NoCompression); //Dictionary<string, HashSet<uint>> d1 = new Dictionary<string, HashSet<uint>>(); //Biser.Decode_DICT_PROTO_STRING_UINTHASHSET(btx, d1, Compression.eCompressionType.NoCompression); //return; if (textsearchengine == null) { textsearchengine = new DBreezeEngine(@"D:\temp\DBR1\"); } MyTask tsk = null; using (var tran = textsearchengine.GetTransaction()) { var resp = tran.TextSearch("TaskText", new DBreeze.TextSearch.TextSearchRequest() { // SearchLogicType = DBreeze.TextSearch.TextSearchRequest.eSearchLogicType.OR, SearchWords = "Xamarin" }); } return; //Testing External indexer concept. //Table where we will store Docs to be indexed using (var tran = textsearchengine.GetTransaction()) { //we want to use table PendingTextSearchIndexing to communicate with AutomaticIndexer (so we will write into it also) tran.SynchronizeTables("Tasks", "TaskText"); //Storing task tsk = new MyTask() { Id = 1, Description = "Starting with the .NET Framework version 2.0, well if you derive a class from Random and override the Sample method, the distribution provided by the derived class implementation of the Sample method is not used in calls to the base class implementation of the NextBytes method. Instead, the uniform", Notes = "distribution returned by the base Random class is used. This behavior improves the overall performance of the Random class. To modify this behavior to call the Sample method in the derived class, you must also override the NextBytes method" }; //Inserting task value must be, of course tsk tran.Insert<long, byte[]>("Tasks", tsk.Id, null); tran.TextInsertToDocument("TaskText", tsk.Id.To_8_bytes_array_BigEndian(), tsk.Description + " " + tsk.Notes, new DBreeze.TextSearch.TextSearchStorageOptions() { FullTextOnly = false, DeferredIndexing = true }); tsk = new MyTask() { Id = 2, Description = "VI guess in Universal Apps for Xamarin you need to include the assembly when loading embedded resources. I had to change", Notes = "I work on.NET for UWP.This is super interesting and I'd well love to take a deeper look at it after the holiday. If " }; tran.Insert<long, byte[]>("Tasks", tsk.Id, null); tran.TextInsertToDocument("TaskText", tsk.Id.To_8_bytes_array_BigEndian(), tsk.Description + " " + tsk.Notes, new DBreeze.TextSearch.TextSearchStorageOptions() { FullTextOnly = false, DeferredIndexing = true }); tran.Commit(); } return; //using (var tran = textsearchengine.GetTransaction()) //{ // tsk = new MyTask() // { // Id = 2, // ExternalId = "x2", // Description = "Very second task ", // Notes = "small" // }; // sb.Append(tsk.Description + " " + tsk.Notes); // tran.InsertDocumentText("TaskFullTextSearch" + companyId, tsk.Id.To_8_bytes_array_BigEndian(), sb.ToString(), new DBreeze.TextSearch.TextSearchStorageOptions() { FullTextOnly = false }); // tran.Commit(); //} //using (var tran = textsearchengine.GetTransaction()) //{ // var resp = tran.TextSearch("TaskFullTextSearch", new DBreeze.TextSearch.TextSearchRequest() // { // // SearchLogicType = DBreeze.TextSearch.TextSearchRequest.eSearchLogicType.OR, // SearchWords = "review1" // }); //} //return; SpeedStatistic.ToConsole = false; SpeedStatistic.StartCounter("a"); //using (var tran = textsearchengine.GetTransaction()) //{ // tsk = new MyTask() // { // Id = 3, // Description = "test review", // Notes = "metro" // }; // tran.Insert<long, byte[]>("Tasks", tsk.Id, null); // tran.TextInsertToDocument("TaskFullTextSearch", tsk.Id.To_8_bytes_array_BigEndian(), tsk.Description + " " + tsk.Notes, new DBreeze.TextSearch.TextSearchStorageOptions() { FullTextOnly = false, }); // //tran.TextAppendWordsToDocument("TaskFullTextSearch", tsk.Id.To_8_bytes_array_BigEndian(), "cheater", new DBreeze.TextSearch.TextSearchStorageOptions() { FullTextOnly = false, }); // //tran.TextRemoveWordsFromDocument("TaskFullTextSearch", tsk.Id.To_8_bytes_array_BigEndian(), "cheater", new DBreeze.TextSearch.TextSearchStorageOptions() { FullTextOnly = true, }); // tran.Commit(); //} //return; using (var tran = textsearchengine.GetTransaction()) { //we want to store text index in table “TaskFullTextSearch” and task itself in table "Tasks" tran.SynchronizeTables("Tasks", "TaskFullTextSearch"); //Storing task tsk = new MyTask() { Id = 1, Description = "Starting with the .NET Framework version 2.0, well if you derive a class from Random and override the Sample method, the distribution provided by the derived class implementation of the Sample method is not used in calls to the base class implementation of the NextBytes method. Instead, the uniform", Notes = "distribution returned by the base Random class is used. This behavior improves the overall performance of the Random class. To modify this behavior to call the Sample method in the derived class, you must also override the NextBytes method" }; tran.Insert<long, byte[]>("Tasks", tsk.Id, null); //Creating text, for the document search. any word or word part (minimum 3 chars, check TextSearchStorageOptions) from Description and Notes will return us this document in the future tran.TextInsertToDocument("TaskFullTextSearch", tsk.Id.To_8_bytes_array_BigEndian(), tsk.Description + " " + tsk.Notes, new DBreeze.TextSearch.TextSearchStorageOptions() { FullTextOnly = false, }); tsk = new MyTask() { Id = 2, Description = "VI guess in Universal Apps for Xamarin you need to include the assembly when loading embedded resources. I had to change", Notes = "I work on.NET for UWP.This is super interesting and I'd well love to take a deeper look at it after the holiday. If " }; tran.Insert<long, byte[]>("Tasks", tsk.Id, null); tran.TextInsertToDocument("TaskFullTextSearch", tsk.Id.To_8_bytes_array_BigEndian(), tsk.Description + " " + tsk.Notes, new DBreeze.TextSearch.TextSearchStorageOptions() { FullTextOnly = false, }); tsk = new MyTask() { Id = 3, Description = "Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met", Notes = "This clause was objected to on the grounds that as people well changed the license to reflect their name or organization it led to escalating advertising requirements when programs were combined together in a software distribution: every occurrence of the license with a different name required a separate acknowledgment. In arguing against it, Richard Stallman has stated that he counted 75 such acknowledgments " }; tran.Insert<long, byte[]>("Tasks", tsk.Id, null); tran.TextInsertToDocument("TaskFullTextSearch", tsk.Id.To_8_bytes_array_BigEndian(), tsk.Description + " " + tsk.Notes, new DBreeze.TextSearch.TextSearchStorageOptions() { FullTextOnly = false, }); //Committing all together. //Though its possible to build an automatic indexer for the huge text and call it in parallel thread and here to store only changed documentIDs which must be indexed. //All depends upon necessary insert speed. tran.Commit(); } SpeedStatistic.PrintOut("a",true); }