private IEnumerator FlagRoutine(BoolFlag completeFlag) { while (!completeFlag.Flag) { yield return(null); } }
public bool GetFlagBool(string key) { Flag f = null; flagsDictionary.TryGetValue(key, out f); BoolFlag bF = f as BoolFlag; return((bF != null) ? bF.Get() : false); }
private void Start() { ButtonEffect[0].GetComponent <Button>().Select(); ButtonEffect[2].GetComponent <TextEffect1>().enabled = true; ButtonBuf = ButtonEffect[2]; EventSystemObj = GameObject.Find("EventSystem"); rank = EventSystemObj.GetComponent <BoolFlag>(); rankTmp = rank.getfRank(); }
private IEnumerator SaveAsRoutine(string explorerTitle) { yield return(FileExplorer.Instance.SaveFile(explorerTitle, null, "emc")); if (FileExplorer.Instance.LastResult == null) { yield break; } var errorFlag = new BoolFlag(); yield return(Serialize(FileExplorer.Instance.LastResult, errorFlag)); }
private Coroutine Serialize(string path, BoolFlag errorFlag, bool handleCompletion = true) { DatabaseManager.Instance.ResetProgress(); ProgressDialog.Instance.Show("Сохранение проекта"); var completeFlag = new BoolFlag(); var task = new Task(async() => { try { await ProjectSerializer.Serialize(path); } catch (Exception ex) { await new WaitForUpdate(); if (!DatabaseManager.Instance.IsConnected) { DatabaseManager.Instance.Connect(); } errorFlag.Flag = true; completeFlag.Flag = true; ProgressDialog.Instance.Hide(); ErrorDialog.Instance.ShowError("Не удалось сохранить проект.", ex); return; } _project.Path = FileExplorer.Instance.LastResult; _project.WasChanged = false; await new WaitForUpdate(); errorFlag.Flag = false; completeFlag.Flag = true; if (handleCompletion) { ProgressDialog.Instance.Hide(); PopupManager.Instance.PopSuccess("Проект успешно сохранен"); } }); task.Start(); return(StartCoroutine(FlagRoutine(completeFlag))); }
private Coroutine Deserialize(string path, BoolFlag errorFlag) { DatabaseManager.Instance.ResetProgress(); ProgressDialog.Instance.Show("Восстановление проекта"); var completeFlag = new BoolFlag(); var persistentPath = Application.persistentDataPath; var temporaryPath = Application.temporaryCachePath; var task = new Task(async() => { try { await ProjectSerializer.Deserialize(path, persistentPath, temporaryPath); } catch (Exception ex) { await new WaitForUpdate(); errorFlag.Flag = true; completeFlag.Flag = true; ProgressDialog.Instance.Hide(); ErrorDialog.Instance.ShowError("Не удалось восстановить проект.", ex); return; } await new WaitForUpdate(); errorFlag.Flag = false; completeFlag.Flag = true; _project.Path = FileExplorer.Instance.LastResult; _project.WasChanged = false; ProgressDialog.Instance.Hide(); PopupManager.Instance.PopSuccess("Проект успешно восстановлен"); }); task.Start(); return(StartCoroutine(FlagRoutine(completeFlag))); }
/// <summary> /// Shut down all threads in the threadpool and executes any remaining tasks. /// </summary> public static void Terminate() { TerminateFlag.FalseToTrue(); BoolFlag Flag = new BoolFlag(); Thread EndThread = new Thread(new ThreadStart(delegate { while (!Flag.EndFlag.Value) { Event.Set(); } })); EndThread.Start(); foreach (Thread t in Threads) { t.Join(); } Flag.EndFlag.FalseToTrue(); EndThread.Join(); PromiseBase Promise; while (TaskQueue.TryDequeue(out Promise)) { Promise.Execute(); } while (BackgroundTaskQueue.TryDequeue(out Promise)) { Promise.Execute(); } TaskQueue = null; BackgroundTaskQueue = null; Threads = null; Event = null; BackgroundEvent = null; }
private IEnumerator LoadRoutine(string path) { if (path == null) { yield return(FileExplorer.Instance.OpenFile("Открыть Проект", null, "emc")); if (FileExplorer.Instance.LastResult == null) { yield break; } path = FileExplorer.Instance.LastResult; if (_project != null) { if (_project.WasChanged) { yield return(QuestionDialog.Instance.Open("Внимание!", "Если не сохранить, проект изменения будут потеряны.\nСохранить проект?")); if (QuestionDialog.Instance.Answer == QuestionDialog.AnswerType.Cancel) { yield break; } if (QuestionDialog.Instance.Answer == QuestionDialog.AnswerType.Yes) { string serializePath = null; if (string.IsNullOrEmpty(_project.Path)) { yield return(FileExplorer.Instance.SaveFile("Сохранить проект", null, "emc")); if (FileExplorer.Instance.LastResult == null) { yield break; } serializePath = FileExplorer.Instance.LastResult; } else { serializePath = _project.Path; } var serializeErrorFlag = new BoolFlag(); yield return(Serialize(serializePath, serializeErrorFlag, false)); if (serializeErrorFlag.Flag) { yield break; } } } Closed.Invoke(); } } _project = new Project(); Created.Invoke(); ProgressDialog.Instance.Hide(); var DeserializeErrorFlag = new BoolFlag(); yield return(Deserialize(path, DeserializeErrorFlag)); if (DeserializeErrorFlag.Flag) { CloseWithoutQuestions(); yield break; } _project.Path = path; _project.WasChanged = false; }
private void Start() { EventSystem = GameObject.Find("EventSystem"); rank = EventSystem.GetComponent <BoolFlag>(); }
static void Main(string[] args) { var app = Cli.NewApp(); app.Authors.Add("r.uchiyama"); app.Usage = "Hyper-V Command Tools"; // Global Flags var outputOption = new StringFlag("output"); outputOption.Alias = new string[] { "out", "o" }; outputOption.Usage = "Choose Output format."; outputOption.SetDefaultValue("json"); var serverOption = new StringFlag("server"); serverOption.Alias = new string[] { "svr", "s" }; serverOption.Usage = "Choose Execute Server"; serverOption.SetDefaultValue(""); var loggerOption = new BoolFlag("logger"); loggerOption.Usage = "Use Logger"; loggerOption.SetDefaultValue(false); app.Flags.Add(outputOption); app.Flags.Add(serverOption); app.Flags.Add(loggerOption); #region vm command // vm command var vmCommand = new Command("vm"); vmCommand.Usage = "Virtual Machine Action"; // vm list var vm_ListCommand = new Command("list"); vm_ListCommand.Action = (ctx) => { PowerShellResult result; using (var p = PowerShellProcess.Default("Get-VM")) { ApplyLogger(p, ctx.Bool("logger")); p.RemoteServer = ctx.String("server"); result = Execute(p, Output.GetOutputs(ctx.String("output"))); } WriteResult(result); }; // vm start var vm_StartCommand = new Command("start"); var nameOption = new StringFlag("name"); nameOption.Alias = new string[] { "n" }; nameOption.Usage = "The name of the Virtual Machine."; vm_StartCommand.Flags.Add(nameOption); vm_StartCommand.Action = (ctx) => { PowerShellResult result; string name = ctx.String("name"); if (string.IsNullOrEmpty(name)) { Console.WriteLine("name not found"); return; } using (var p = PowerShellProcess.Default("Start-VM")) { p.AddFlag("-Name", name); p.RemoteServer = ctx.String("server"); ApplyLogger(p, ctx.Bool("logger")); result = Execute(p, Output.GetOutputs(ctx.String("output"))); } WriteResult(result); }; // vm stop var vm_StopCommand = new Command("stop"); vm_StopCommand.Flags.Add(nameOption); vm_StopCommand.Action = (ctx) => { PowerShellResult result; string name = ctx.String("name"); if (string.IsNullOrEmpty(name)) { Console.WriteLine("name not found"); return; } using (var p = PowerShellProcess.Default("Stop-VM")) { p.AddFlag("-Name", name); p.RemoteServer = ctx.String("server"); ApplyLogger(p, ctx.Bool("logger")); result = Execute(p, Output.GetOutputs(ctx.String("output"))); } WriteResult(result); }; // vm list-ip-addresses var vm_ListIpAddressesCommand = new Command("list-ip-addresses"); vm_ListIpAddressesCommand.Action = (ctx) => { PowerShellResult result; using (var p = PowerShellProcess.Default("Get-VM")) { p.AddPipe().AddCommand("select").AddFlag("-ExpandProperty", "NetworkAdapters").AddPipe().AddCommand("select").AddParameters("VMName", ",IPAddresses"); p.RemoteServer = ctx.String("server"); ApplyLogger(p, ctx.Bool("logger")); result = Execute(p, Output.GetOutputs(ctx.String("output"))); } WriteResult(result); }; vmCommand.SubCommands.Add(vm_ListCommand); vmCommand.SubCommands.Add(vm_StartCommand); vmCommand.SubCommands.Add(vm_StopCommand); vmCommand.SubCommands.Add(vm_ListIpAddressesCommand); app.Commands.Add(vmCommand); #endregion app.Run(args); }