private void OnReceivePacket(object sender, MessageReceivedEventArgs e) { //6~7ms rate if (data == null || !IsRunning) { return; } try { uint pktID = (uint)e.Message.WParam; packet = data.GetDataPacket(pktID); if (packet.pkContext.IsValid) { lock (dataWriteLock) { MarkActive(); pressure = (float)packet.pkNormalPressure.pkAbsoluteNormalPressure / maxNormalPressure; distance = (float)packet.pkZ / maxTangentPressure; position = new Vector2(packet.pkX, packet.pkY) / OutputExtFactor; position.y = systemRect.yMax - position.y + systemRect.yMin; } } } catch (Exception ex) { GDebug.Log(ex.ToString(), GLogLevel.Warnning); } }
private GWait CastWaitOrder(object returnObject) { GWait waitOrder = null; if (returnObject == null) { waitOrder = new GWait(GTimeUnit.Frame, 1); } else { if (returnObject is GWait) { waitOrder = (GWait)returnObject; } else if (returnObject is IEnumerator) { IEnumerator coroutine = (IEnumerator)returnObject; GRoutine targetRoutine = ownerCore.AddGRoutine(coroutine); delayRoutine = targetRoutine; } else if (routine.Current is GRoutine) { GRoutine targetRoutine = (GRoutine)returnObject; delayRoutine = targetRoutine; } else { GDebug.Log("지원되지 않는 반환 형식입니다. 'GWait', 'GRoutine', 'IEnumerator' 클래스를 반환하세요.", GLogLevel.Error); waitOrder = new GWait(GTimeUnit.Frame, 1); } } return(waitOrder); }
public static void Set(string KeyName, bool enable, string arg = null) { try { RegistryKey startupKey = Registry.CurrentUser.OpenSubKey(runKey, true); if (enable) { Set(KeyName, false); string value = "\"" + IOUtility.AppFileInfo.FullName.Replace('/', '\\') + "\" "; if (!string.IsNullOrEmpty(arg)) { value += arg; } startupKey.SetValue(KeyName, value); startupKey.Close(); } else { startupKey.DeleteValue(KeyName, false); startupKey.Close(); } } catch (Exception ex) { GDebug.Log(ex.ToString(), GLogLevel.Warnning); } }
public static void MoveAllFiles(DirectoryInfo originInfo, DirectoryInfo destInfo) { try { destInfo.Create(); foreach (FileInfo fileInfo in originInfo.GetFiles()) { try { string newFilePath = Path.Combine(destInfo.FullName, fileInfo.Name); if (File.Exists(newFilePath)) { File.Delete(newFilePath); } fileInfo.MoveTo(newFilePath); } catch (Exception ex) { GDebug.Log(ex.ToString()); } } foreach (DirectoryInfo subDirectory in originInfo.GetDirectories()) { DirectoryInfo nextDestDir = destInfo.CreateSubdirectory(subDirectory.Name); MoveAllFiles(subDirectory, nextDestDir); } } catch (Exception ex) { GDebug.Log(ex.ToString()); } }
/// <summary> /// 함수를 호출하며 예외를 검사합니다. /// </summary> public static bool TryInvoke(this Action action) { try { action?.Invoke(); return(true); } catch (Exception ex) { GDebug.Log(ex.ToString(), GLogLevel.Warnning); return(false); } }
public static bool Get(string KeyName) { try { RegistryKey startupKey = Registry.CurrentUser.OpenSubKey(runKey, true); return(startupKey.GetValue(KeyName) != null); } catch (Exception ex) { GDebug.Log(ex.ToString(), GLogLevel.Warnning); } return(false); }
public static bool Start(string path, string args = null) { try { Process process = new Process(); process.StartInfo.FileName = path; if (!string.IsNullOrEmpty(args)) { process.StartInfo.Arguments = args; } process.Start(); return(true); } catch (Exception ex) { GDebug.Log(ex.ToString(), GLogLevel.Warnning); return(false); } }
internal bool Run(float deltaMillisec) { try { if (UpdateTime(deltaMillisec)) { return(true); } if (delayMillisec <= 0f) { bool hasValue = routine.MoveNext(); if (hasValue) { object returnObject = routine.Current; GWait waitOrder = CastWaitOrder(returnObject); if (waitOrder != null) { switch (waitOrder.unit) { case GTimeUnit.Frame: delayFrame += (int)waitOrder.time; break; case GTimeUnit.Millisecond: delayMillisec += waitOrder.time; break; case GTimeUnit.Second: delayMillisec += waitOrder.time * 1000f; break; } } } else { Complete(); } return(hasValue); } return(true); } catch (Exception ex) { GDebug.Log(ex.ToString(), GLogLevel.Error); Complete(); return(false); } }
public bool Execute() { if (delayMillisec <= 0f) { try { action(); } catch (Exception ex) { GDebug.Log($"{nameof(GJobManager)} ::{Environment.NewLine}{ex.ToString()}"); } watch.Stop(); watch = null; return(true); } else { delayMillisec -= DeltaMillisec; watch.Restart(); return(false); } }