private void WebWorkerQueueTest() { DCT.ExecuteAsync(c => { ConsoleHelper.SendMessage("Start"); //Start for (int i = 0; i < 100; i++) { var ii = i; var result = ii.ToString(); WebWorker.Current.Execute(() => { Thread.Sleep(100 - ii); ConsoleHelper.SendMessage(result); }); } Thread.Sleep(10000); //Continue for (int i = 101; i < 130; i++) { var result = i.ToString(); WebWorker.Current.Execute(() => ConsoleHelper.SendMessage(result)); } //Break Thread.Sleep(35000); //New start for (int i = 131; i < 250; i++) { var result = i.ToString(); WebWorker.Current.Execute(() => ConsoleHelper.SendMessage(result)); } ConsoleHelper.SendMessage("Finish"); }); }
public override void EditBulletins(IEnumerable <TaskCache_old> tasks) { DCT.Execute(d => { var accessContainer = AccessContainerList.Get(Uid); foreach (var task in tasks) { var bulletin = task.BulletinPackage; if (accessContainer.TryAuth(bulletin.Access)) { PrepareBulletin(bulletin); ContinueAddOrEdit(EnumHelper.GetValue <BulletinState>(bulletin.State)); Publicate(bulletin); } } DCT.ExecuteAsync(d2 => { foreach (var task in tasks) { var bulletin = task.BulletinPackage; if (string.IsNullOrEmpty(bulletin.Url)) { bulletin.State = (int)BulletinState.Error; task.State = (int)TaskCacheState.Error; } else { bulletin.State = (int)BulletinState.OnModeration; task.State = (int)TaskCacheState.Completed; } } //DriverTaskHelper.Complete(tasks); }); }); }
internal static void Execute(Action action, bool isAsync = true, string name = "") { DCT.Execute(data => { if (action == null) { throw new NullReferenceException("CurrentDispatcher.Execute - Action не может быть пустым"); } //Если контекст синхронизации не доступен в данном приложении if (CurrentSynchronizationContext == null) { DCT.SendInformations($"Тип вызова TaskAsync", "DispatcherHelper"); DCT.ExecuteAsync(c => action()); return; } DCT.SendInformations($"Тип вызова SynchronizationContext IsAsync={isAsync}", "DispatcherHelper"); if (isAsync) { CurrentSynchronizationContext.Post((a) => execute(a), action); } else { CurrentSynchronizationContext.Send((a) => execute(a), action); } }, name: "DispatcherHelper"); }
internal static void Execute() { DCT.ExecuteAsync(d => { AskForWork(); }, continueMethod: c => Application.Current.Shutdown()); }
private static void DCTNameTest() { DCT.Execute(c => { }); DCT.Execute <string>(c => { return(""); }); DCT.ExecuteAsync(c => { }); DCT.ExecuteAsync <string>(c => { return(""); }, (c, result) => { }); DCT.ExecuteMainThread(c => { }); }
public static void _PrepareInstances(IEnumerable <BulletinPackage> bulletins, Action <IEnumerable <BulletinPackage> > action = null) { DCT.ExecuteAsync(d2 => { using (var client = new ServiceClient()) client.CreateBulletins(bulletins, action); }); }
public static void _PrepareInstance(BulletinPackage obj, Action <BulletinPackage> action = null) { DCT.ExecuteAsync(d2 => { using (var client = new ServiceClient()) client.CreateBulletin(obj, action); }); }
public static void _CreateAccess(AccessCache obj, Action <AccessCache> action = null) { DCT.ExecuteAsync(d => { using (var client = new ServiceClient()) client.CreateAccess(obj, action); }); }
public static void _CloneBulletin(BulletinPackage obj, Action <BulletinPackage> action = null) { DCT.ExecuteAsync(d2 => { using (var client = new ServiceClient()) client.CloneBulletins(obj, action); }); }
public static void AccessWorkResult(IEnumerable <AccessCache> accesses) { DCT.ExecuteAsync(d2 => { using (var client = new EngineService()) { var r = client.Ping(); Console.WriteLine($"Ping = {r}"); client.SendQueryCollection("CheckAccess", objects: accesses); } }); }
public static void AccessBulletinDetailsWorkDone(IEnumerable <TaskCache_old> tasks) { DCT.ExecuteAsync(d2 => { using (var client = new EngineService()) { var r = client.Ping(); Console.WriteLine($"Ping = {r}"); client.SendQueryCollection("Save", objects: tasks); } }); }
public static void BulletinWorkDone(IEnumerable <BulletinPackage> bulletins) { DCT.ExecuteAsync(d2 => { using (var client = new EngineService()) { var r = client.Ping(); Console.WriteLine($"Ping = {r}"); client.SendQueryCollection("Save", objects: bulletins); } }); }
public void AddImage(Action <Response_AddImage> callback, string name, byte[] image) { Response_AddImage response = null; DCT.ExecuteAsync(c => { var request = new Request_AddImage() { Image = image, Name = name, }; Execute(request, callback); }); }
static void SignInCallback(bool result) { DCT.Execute(c => { if (result) { Console.WriteLine($"Signin succesfull"); clientHash = c._SessionInfo.HashUID; sessionHash = c._SessionInfo.SessionUID; DCT.ExecuteAsync(cc => GetDataCollection()); } else { Console.WriteLine($"Signin not sucessfull"); } Console.WriteLine($"SessionUID Request = {c._SessionInfo.SessionUID}"); Console.WriteLine($"HashUID Request = {c._SessionInfo.HashUID}"); }); }
public override void AddBulletins(IEnumerable <BulletinPackage> packages) { UiHelper.UpdateWorkState("Добавление списка буллетинов"); DCT.Execute(d => { var createdBulletins = new List <BulletinPackage>(); { var fieldValueContainer = FieldValueContainerList.Get(Uid); var accessContainer = AccessContainerList.Get(Uid); foreach (var bulletin in packages) { var name = bulletin.ValueFields["Название объявления"]; UiHelper.UpdateObjectState($"Bulletin {name}, state = {bulletin.State}"); UiHelper.UpdateActionState("Попытка авторизоваться"); if (accessContainer.TryAuth(bulletin.Access)) { UiHelper.UpdateActionState("Ожидание прогрузки страницы"); Thread.Sleep(2000); UiHelper.UpdateActionState("Переход на страницу - additem"); Thread.Sleep(1000); UiHelper.UpdateActionState("Выбор категорий"); ChooseCategories(bulletin.Signature); UiHelper.UpdateActionState("Установка значений"); Thread.Sleep(1000); SetValueFields(bulletin, fieldValueContainer); Thread.Sleep(1000); ContinueAddOrEdit(EnumHelper.GetValue <BulletinState>(bulletin.State)); Thread.Sleep(1000); Publicate(bulletin); Thread.Sleep(1000); GetUrl(bulletin); Thread.Sleep(1000); } } } { DCT.ExecuteAsync(d2 => { UiHelper.UpdateActionState("Проверка Url и установка состояний"); Thread.Sleep(1000); foreach (var b in packages) { if (string.IsNullOrEmpty(b.Url)) { b.State = (int)BulletinState.Error; } else { b.State = (int)BulletinState.OnModeration; } var name = b.ValueFields["Название объявления"]; UiHelper.UpdateObjectState($"Bulletin {name}, state = {b.State}"); } UiHelper.UpdateActionState("Отправка коллбека"); Thread.Sleep(1000); }); } }); }