public static IThread StartWorkerThread(string group, string name, ThreadPriority priority, int initialCapacity) { var thread = new WorkerThread(group, name, priority, initialCapacity); thread.Start(); return(thread); }
/// <summary> /// Decodes the GIF file at the provided filepath into an array to textures. /// If framesToRead is smaller than 1 or bigger than the total number of frames in the GIF, the whole file will be read. /// Otherwise, only the number of frames determined by framesToRead will be decoded. /// </summary> /// <param name="filepath"></param> /// <param name="framesToRead"></param> /// <param name="threadPriority"></param> /// <param name="completeCallback"></param> public static void DecodeGif(string filepath, int framesToRead, System.Threading.ThreadPriority threadPriority, Action <Texture[]> completeCallback) { #if UNITY_EDITOR Debug.LogWarning("DecodeGif is not supported in Unity editor. Please test on an iOS or Android device."); #elif UNITY_IOS // Read the GIF partially. iOSNativeGif.DecodeGif(curDecodeId++, filepath, framesToRead, threadPriority, (int taskId, GifMetadata gifMetadata, GifFrameMetadata[] gifFrameMetadata, Color32[][] imageData) => { if (completeCallback != null) { completeCallback(ToTextureArray(gifMetadata, gifFrameMetadata, imageData)); } }); #elif UNITY_ANDROID // Read the GIF partially. AndroidNativeGif.DecodeGif(curDecodeId++, filepath, framesToRead, threadPriority, (int taskId, GifMetadata gifMetadata, GifFrameMetadata[] gifFrameMetadata, Color32[][] imageData) => { if (completeCallback != null) { completeCallback(ToTextureArray(gifMetadata, gifFrameMetadata, imageData)); } }); #endif }
public void Start() { if (false.Equals(m_Enabled.Equals(uint.MinValue))) { return; } if (IsDisposed) { throw new System.ObjectDisposedException("The Timer has already been disposed."); } Change(m_Frequency, System.TimeSpan.Zero); m_Counter.Start(); System.Threading.ThreadPriority previous = System.Threading.Thread.CurrentThread.Priority; System.Threading.Thread.CurrentThread.Priority = System.Threading.ThreadPriority.Lowest; while (false.Equals(m_Enabled.Equals(uint.MinValue)) && m_Ops == 0) { if (System.Threading.Thread.CurrentThread.Equals(m_Counter)) { m_Counter.Join(System.TimeSpan.Zero); //++m_Ops; } else { m_Counter.Join(System.Threading.Timeout.InfiniteTimeSpan); //++m_Ops; } } System.Threading.Thread.CurrentThread.Priority = previous; }
public void SetThreadPriority(System.Threading.ThreadPriority priority) { lock (m_lock) if (m_currentBackupControlInterface != null) { m_currentBackupControlInterface.SetThreadPriority(priority); } }
/// <summary> /// /// </summary> /// <param name="id"></param> /// <param name="type"></param> /// <param name="priority"></param> /// <param name="threadCount"></param> /// <param name="path"></param> public ThreadManagementLookupEntry(Guid id, TransactionType type, System.Threading.ThreadPriority priority, int threadCount, String path) { ExecutionEngineId = id; ThreadTransactionType = type; ThreadPriority = priority; MaxThreadCount = threadCount; QueuePath = path; }
public void SetRunning(System.Threading.Thread thread, System.Threading.ThreadPriority priority) { if (object.ReferenceEquals(thread, null) || false.Equals(thread.IsAlive)) { return; } thread.Priority = priority; }
//Methods or statics for OperationCountToTimeSpan? (Estimate) public void NanoSleep(int nanos) { System.Threading.ThreadPriority previous = System.Threading.Thread.CurrentThread.Priority; System.Threading.Thread.CurrentThread.Priority = System.Threading.ThreadPriority.Highest; Clock.NanoSleep((long)nanos, AverageOperationsPerTick); System.Threading.Thread.CurrentThread.Priority = previous; }
public override void Reset() { animatedClip = null; fileName = null; loop = 0; quality = 80; threadPriority = System.Threading.ThreadPriority.Normal; progress = null; gifFilePath = null; eventTarget = null; exportingEvent = null; exportCompletedEvent = null; }
/// <summary> /// Start the work process. /// This should initialize the Thread with the Run function. /// </summary> /// <param name="backgroundThread">If set to <c>true</c> background thread.</param> /// <param name="priority">Priority.</param> public override void Start(bool backgroundThread, System.Threading.ThreadPriority priority) { // Create our new thread. _thread = new System.Threading.Thread(Run); // Establish threads background. _thread.IsBackground = backgroundThread; // Establish the threads priority. _thread.Priority = priority; // Start working! _thread.Start(); }
public void SleepFor(System.Threading.Thread thread, System.TimeSpan timeout, System.Threading.ThreadPriority priority) { if (object.ReferenceEquals(thread, null) || thread.ThreadState.HasFlag(System.Threading.ThreadState.WaitSleepJoin)) { return; } System.Threading.ThreadPriority previous = thread.Priority; thread.Priority = priority; System.Threading.Thread.Sleep(timeout); thread.Priority = previous; }
public bool JoinFor(System.Threading.Thread thread, System.Threading.ThreadPriority priority, System.TimeSpan timeout) { if (object.ReferenceEquals(thread, null) || thread.ThreadState.HasFlag(System.Threading.ThreadState.WaitSleepJoin)) { return(false); } System.Threading.ThreadPriority previous = thread.Priority; thread.Priority = priority; try { return(thread.Join(timeout)); } catch { throw; } finally { thread.Priority = previous; } }
public void SleepFor(System.Threading.Thread thread, System.TimeSpan timeout, System.Threading.ThreadPriority priority) { if (object.ReferenceEquals(thread, null) || thread.ThreadState.HasFlag(System.Threading.ThreadState.WaitSleepJoin)) { return; } System.Threading.ThreadPriority previous = thread.Priority; thread.Priority = priority; System.Threading.Thread.Sleep(timeout); //Would need to inject into stack the sleep call... or suspend resume... thread.Priority = previous; }
static StackObject *set_Priority_2(ILIntepreter __intp, StackObject *__esp, IList <object> __mStack, CLRMethod __method, bool isNewObj) { ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain; StackObject *ptr_of_this_method; StackObject *__ret = ILIntepreter.Minus(__esp, 2); ptr_of_this_method = ILIntepreter.Minus(__esp, 1); System.Threading.ThreadPriority @value = (System.Threading.ThreadPriority) typeof(System.Threading.ThreadPriority).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack)); __intp.Free(ptr_of_this_method); ptr_of_this_method = ILIntepreter.Minus(__esp, 2); System.Threading.Thread instance_of_this_method = (System.Threading.Thread) typeof(System.Threading.Thread).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack)); __intp.Free(ptr_of_this_method); instance_of_this_method.Priority = value; return(__ret); }
public ThreadTechnique(TextBoxOutputManager textBoxOutputManager, System.Threading.ThreadPriority threadPriority) { blockedUniverseUpdThread = false; blockedScreenUpdThread = false; om = textBoxOutputManager; universeUpdThread = new Task(() => { System.Threading.Thread.CurrentThread.Priority = threadPriority; UniverseUpdateLoop(); }); universeUpdThread.Start(); screenUpdThread = new Task(() => { System.Threading.Thread.CurrentThread.Priority = threadPriority; UniverseUpdateLoop(); }); screenUpdThread.Start(); }
public static Alt.Threading.ThreadPriority ToThreadPriority(System.Threading.ThreadPriority src) { switch (src) { case System.Threading.ThreadPriority.Lowest: return(Alt.Threading.ThreadPriority.Lowest); case System.Threading.ThreadPriority.BelowNormal: return(Alt.Threading.ThreadPriority.BelowNormal); case System.Threading.ThreadPriority.Normal: return(Alt.Threading.ThreadPriority.Normal); case System.Threading.ThreadPriority.AboveNormal: return(Alt.Threading.ThreadPriority.AboveNormal); case System.Threading.ThreadPriority.Highest: return(Alt.Threading.ThreadPriority.Highest); } return(Alt.Threading.ThreadPriority.Normal); }
/// <summary> /// Decodes the GIF file at the provided filepath into an <see cref="AnimatedClip"/> object. /// If framesToRead is smaller than 1 or bigger than the total number of frames in the GIF, the whole file will be read. /// Otherwise, only the number of frames determined by framesToRead will be decoded. /// </summary> /// <param name="filepath"></param> /// <param name="framesToRead"></param> /// <param name="threadPriority"></param> /// <param name="completeCallback"></param> public static void DecodeGif(string filepath, int framesToRead, System.Threading.ThreadPriority threadPriority, Action <AnimatedClip> completeCallback) { #if UNITY_EDITOR EM_3DI70R_GIF.DecodeRequest request = new EM_3DI70R_GIF.DecodeRequest(filepath) { frameToRead = framesToRead, threadPriority = threadPriority }; request.Completed += () => { if (completeCallback != null) { completeCallback(request.AnimatedClip); } }; request.Request(); // Debug.LogWarning("DecodeGif is not supported in Unity editor. Please test on an iOS or Android device."); #elif UNITY_IOS // Read the GIF partially. iOSNativeGif.DecodeGif(curDecodeId++, filepath, framesToRead, threadPriority, (int taskId, GifMetadata gifMetadata, GifFrameMetadata[] gifFrameMetadata, Color32[][] imageData) => { if (completeCallback != null) { completeCallback(ToAnimatedClip(gifMetadata, gifFrameMetadata, imageData)); } }); #elif UNITY_ANDROID // Read the GIF partially. AndroidNativeGif.DecodeGif(curDecodeId++, filepath, framesToRead, threadPriority, (int taskId, GifMetadata gifMetadata, GifFrameMetadata[] gifFrameMetadata, Color32[][] imageData) => { if (completeCallback != null) { completeCallback(ToAnimatedClip(gifMetadata, gifFrameMetadata, imageData)); } }); #endif }
static string PriorityToString(System.Threading.ThreadPriority priority) { switch (priority) { case System.Threading.ThreadPriority.Highest: return(ResourceService.GetString("MainWindow.Windows.Debug.Threads.Priority.Highest")); case System.Threading.ThreadPriority.AboveNormal: return(ResourceService.GetString("MainWindow.Windows.Debug.Threads.Priority.AboveNormal")); case System.Threading.ThreadPriority.Normal: return(ResourceService.GetString("MainWindow.Windows.Debug.Threads.Priority.Normal")); case System.Threading.ThreadPriority.BelowNormal: return(ResourceService.GetString("MainWindow.Windows.Debug.Threads.Priority.BelowNormal")); case System.Threading.ThreadPriority.Lowest: return(ResourceService.GetString("MainWindow.Windows.Debug.Threads.Priority.Lowest")); default: return(ResourceService.GetString("Global.NA")); } }
private static int EncodeThreadPriority(System.Threading.ThreadPriority priority) { switch (priority) { case System.Threading.ThreadPriority.Lowest: return(-2); case System.Threading.ThreadPriority.BelowNormal: return(-1); case System.Threading.ThreadPriority.Normal: return(0); case System.Threading.ThreadPriority.AboveNormal: return(1); case System.Threading.ThreadPriority.Highest: return(2); default: return(0); } }
public static void SetThreadPriority(System.Threading.ThreadPriority priority) { Instance.m_worker.SetThreadPriority(priority); }
/// <summary> /// Default constructor /// </summary> internal LiveControl(System.Threading.Thread owner, Options options) { m_owner = owner; m_options = options; m_defaultPriority = m_owner.Priority; m_downloadLimit = m_options.MaxDownloadPrSecond; m_uploadLimit = m_options.MaxUploadPrSecond; }
/// <summary> /// Exports a GIF image from the provided clip. /// Allows setting looping mode of the output image. /// </summary> /// <param name="clip">The clip to export to GIF format.</param> /// <param name="filename">Filename to save the output GIF.</param> /// <param name="loop">-1 to disable, 0 to loop indefinitely, >0 to loop a set number of times.</param> /// <param name="quality">Quality setting for the exported image. Inputs will be clamped between 1 and 100. Bigger values mean better quality but slightly longer processing time. 80 is generally a good value in terms of time-quality balance.</param> /// <param name="threadPriority">Priority of the GIF encoding thread.</param> /// <param name="exportProgressCallback">Export progress callback: 1st parameter is the provided clip, 2nd parameter is the export progress from 0 to 1.</param> /// <param name="exportCompletedCallback">Export completed callback: 1st parameter is the provided clip, 2nd parameter is the filepath of the exported GIF.</param> public static void ExportGif(AnimatedClip clip, string filename, int loop, int quality, System.Threading.ThreadPriority threadPriority, Action <AnimatedClip, float> exportProgressCallback, Action <AnimatedClip, string> exportCompletedCallback) { if (clip == null || clip.Frames.Length == 0 || clip.IsDisposed()) { Debug.LogError("Attempted to export GIF from an empty or disposed clip."); return; } if (String.IsNullOrEmpty(filename)) { Debug.LogError("Exporting GIF failed: filename is null or empty."); return; } // Start the actual export process Instance.StartCoroutine(CRExportGif(clip, filename, loop, quality, threadPriority, exportProgressCallback, exportCompletedCallback)); }
/// <summary> /// Decodes the GIF file at the provided filepath into an <see cref="AnimatedClip"/> object. /// </summary> /// <param name="filepath"></param> /// <param name="threadPriority"></param> /// <param name="completeCallback"></param> public static void DecodeGif(string filepath, System.Threading.ThreadPriority threadPriority, Action <AnimatedClip> completeCallback) { DecodeGif(filepath, -1, threadPriority, completeCallback); // framesToRead == -1: read the whole GIF }
/// <summary> /// Start the work process, should probably send the Run function to the thread! /// </summary> /// <param name="backgroundThread">If set to <c>true</c> the thread will be set to background.</param> /// <param name="priority">The thread priority.</param> public abstract void Start(bool backgroundThread, System.Threading.ThreadPriority priority);
internal static void DecodeGif(int taskId, string filepath, System.Threading.ThreadPriority workerPriority, DecodeCompleteCallback completeCallback) { DecodeGif(taskId, filepath, -1, workerPriority, completeCallback); // framesToRead == -1: read whole GIF }
public static void submitHelper() { string filename = submit_filename; bool remember = Component.compiled_flowchart; string s; int num_input_files = 0; bool passed = true; // directory is a special case-- don't allow it if (filename.ToLower() == "directory") { MessageBox.Show("No tests found for: " + filename + "\n\nUse Save As to change filename.\n" + "View available tests using Select Server (Run menu).", "Check filename", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } // connect to server and test try { try { string ts = Registry_Settings.Read("test_server"); string tp = Registry_Settings.Read("test_port"); if (!Component.BARTPE) { Connect_To_Server(ts, System.Int32.Parse(tp)); } else { Connect_To_Executable(); } } catch (System.Exception e) { throw new System.Exception(); } try { //string x = this.assignmentsCombo.SelectedItem+"\r\n"; string x = filename + "\r\n"; byte[] buffer = System.Text.Encoding.ASCII.GetBytes(x); if (!Component.BARTPE) { raptor_files_pkg.current_socket.Send(buffer); } else { process.StandardInput.WriteLine(filename); process.StandardInput.Flush(); } } catch { MessageBox.Show("Server terminated abnormally.", "Server failed", MessageBoxButtons.OK, MessageBoxIcon.Error); throw new System.Exception(); } try { if (Component.BARTPE && !process.StandardOutput.EndOfStream) { s = process.StandardOutput.ReadLine(); num_input_files = System.Int32.Parse(s); } else { s = raptor_files_pkg.get_line(); num_input_files = System.Int32.Parse(s); } if (num_input_files == 0) { throw new System.Exception(); } } catch { MessageBox.Show("No tests found for: " + filename + "\n\nUse Save As to change filename.\n" + "View available tests using Select Server (Run menu).", "Check filename", MessageBoxButtons.OK, MessageBoxIcon.Error); throw new System.Exception(); } Runtime.consoleClear(); Component.run_compiled_flowchart = true; try { Compile_Helpers.Compile_Flowchart(Runtime.parent.carlisle.TabPages); } catch (parse_tree.emit_code.illegal_code e) { MessageBox.Show("Illegal flowchart: no graphics allowed when testing against server."); throw; } catch (System.Exception e) { MessageBox.Show(e.Message + '\n', "Compilation Error", MessageBoxButtons.OK, MessageBoxIcon.Error); throw; } for (int i = 1; i <= num_input_files; i++) { System.Threading.ThreadPriority priority = System.Threading.Thread.CurrentThread.Priority; System.Threading.Thread.CurrentThread.Priority = System.Threading.ThreadPriority.BelowNormal; try { Compile_Helpers.Run_Compiled_NoThread(false); } catch { MessageBox.Show("Program terminated abnormally", "Program error", MessageBoxButtons.OK, MessageBoxIcon.Error); throw new System.Exception(); } System.Threading.Thread.CurrentThread.Priority = priority; // send the EOF try { string x = "\r\nEOF\r\n"; byte[] buffer = System.Text.Encoding.ASCII.GetBytes(x); if (!Component.BARTPE) { raptor_files_pkg.current_socket.Send(buffer); } else { process.StandardInput.WriteLine(); process.StandardInput.WriteLine("EOF"); process.StandardInput.Flush(); } } catch { MessageBox.Show("Server terminated abnormally", "Network error", MessageBoxButtons.OK, MessageBoxIcon.Error); throw new System.Exception(); } try { // loop until EOF at end of input while (true) { s = raptor_files_pkg.get_line(); } } catch { } try { s = raptor_files_pkg.get_line(); if (s == "INCORRECT") { passed = false; } Runtime.consoleMessage(filename + ": test case #" + i + ": " + s); } catch { Runtime.consoleMessage("no response"); passed = false; } } StopRedirection(); if (passed) { Runtime.consoleMessage(filename + ": PASSED"); } else { Runtime.consoleMessage(filename + ": FAILED"); } Component.run_compiled_flowchart = false; } catch (System.Exception e) { try { StopRedirection(); } catch {} Component.run_compiled_flowchart = false; } }
/// <summary> /// Exports a GIF image from the provided clip. /// </summary> /// <param name="clip">The clip to export to GIF format.</param> /// <param name="filename">Filename to save the output GIF.</param> /// <param name="quality">Quality setting for the exported image. Inputs will be clamped between 1 and 100. Bigger values mean better quality but slightly longer processing time. 80 is generally a good value in terms of time-quality balance.</param> /// <param name="threadPriority">Thread priority to use when exporting GIF file.</param> /// <param name="exportProgressCallback">Export progress callback: 1st parameter is the provided clip, 2nd parameter is the export progress from 0 to 1.</param> /// <param name="exportCompletedCallback">Export completed callback: 1st parameter is the provided clip, 2nd parameter is the filepath of the exported GIF.</param> public static void ExportGif(AnimatedClip clip, string filename, int quality, System.Threading.ThreadPriority threadPriority, Action <AnimatedClip, float> exportProgressCallback, Action <AnimatedClip, string> exportCompletedCallback) { ExportGif(clip, filename, 0, quality, threadPriority, exportProgressCallback, exportCompletedCallback); }
/// <summary> /// Sends the work process to the ThreadPool for starting when resources are available, /// This needs to initialize the WaitCallback with the Run function. /// </summary> /// <param name="backgroundThread">Not Used.</param> /// <param name="priority">Not Used.</param> public override void Start(bool backgroundThread, System.Threading.ThreadPriority priority) { _callback = new System.Threading.WaitCallback(Run); System.Threading.ThreadPool.QueueUserWorkItem(_callback); }
// GIF exporting coroutine: preprocess the image data then send it to native code (mobile) or a worker thread (other platforms) to export GIF file. static IEnumerator CRExportGif(AnimatedClip clip, string filename, int loop, int quality, System.Threading.ThreadPriority threadPriority, Action <AnimatedClip, float> exportProgressCallback, Action <AnimatedClip, string> exportCompletedCallback) { // The encoder don't want loop to be < -1 if (loop < -1) { loop = -1; } // Compute the NeuQuant sample factor from the inverse of the quality value. // Note that NeuQuant prefers values in range [1,30] so we'll also scale the factor to that range. int sampleFac = Mathf.RoundToInt(Mathf.Lerp(30, 1, (float)(Mathf.Clamp(quality, 1, 100)) / 100)); // Construct filepath string folder; #if UNITY_EDITOR folder = Application.dataPath; // Assets folder #else folder = Application.persistentDataPath; #endif string filepath = System.IO.Path.Combine(folder, filename + ".gif"); // Construct a new export task var exportTask = new GifExportTask(); exportTask.taskId = curExportId++; // assign this task a unique id exportTask.clip = clip; exportTask.imageData = null; exportTask.filepath = filepath; exportTask.loop = loop; exportTask.sampleFac = sampleFac; exportTask.exportProgressCallback = exportProgressCallback; exportTask.exportCompletedCallback = exportCompletedCallback; exportTask.workerPriority = threadPriority; exportTask.isExporting = true; exportTask.isDone = false; exportTask.progress = 0; // Add task to the list with its unique id key gifExportTasks.Add(exportTask.taskId, exportTask); yield return(null); // Create a temporary texture to read RenderTexture data Texture2D temp = new Texture2D(clip.Width, clip.Height, TextureFormat.RGB24, false); temp.hideFlags = HideFlags.HideAndDontSave; temp.wrapMode = TextureWrapMode.Clamp; temp.filterMode = FilterMode.Bilinear; temp.anisoLevel = 0; // On iOS and Android, the GIF encoding is done in native code. // In Unity editor (and other platforms), we use Moments encoder for testing purpose. #if UNITY_EDITOR || (!UNITY_IOS && !UNITY_ANDROID) // Converts to GIF frames List <GifFrame> frames = new List <GifFrame>(clip.Frames.Length); for (int i = 0; i < clip.Frames.Length; i++) { RenderTexture source = clip.Frames[i]; RenderTexture.active = source; temp.ReadPixels(new Rect(0, 0, source.width, source.height), 0, 0); temp.Apply(); RenderTexture.active = null; GifFrame frame = new GifFrame() { Width = temp.width, Height = temp.height, Data = temp.GetPixels32() }; frames.Add(frame); OnGifPreProcessing(exportTask.taskId, (float)i / clip.Frames.Length); yield return(null); } // Setup a worker thread and let it do its magic GifEncoder encoder = new GifEncoder(loop, sampleFac); encoder.SetDelay(Mathf.RoundToInt(1000f / clip.FramePerSecond)); Worker worker = new Worker( exportTask.taskId, threadPriority, frames, encoder, filepath, OnGifExportProgress, OnGifExportCompleted); worker.Start(); #else // Allocate an array to hold the serialized image data exportTask.imageData = new Color32[clip.Frames.Length][]; // Construct the serialized image data, note that texture data is layered down-top, so flip it for (int i = 0; i < clip.Frames.Length; i++) { var source = clip.Frames[i]; RenderTexture.active = source; temp.ReadPixels(new Rect(0, 0, source.width, source.height), 0, 0); temp.Apply(); RenderTexture.active = null; // Get the frame's pixel data exportTask.imageData[i] = temp.GetPixels32(); // Call the preprocessing handler directly float progress = (float)i / clip.Frames.Length; OnGifPreProcessing(exportTask.taskId, progress); yield return(null); } #if UNITY_IOS iOSNativeGif.ExportGif(exportTask); #elif UNITY_ANDROID AndroidNativeGif.ExportGif(exportTask); #endif #endif // UNITY_EDITOR || (!UNITY_IOS && !UNITY_ANDROID) // Dispose the temporary texture Destroy(temp); }
internal static Component Step_Once(Component currentObj, Visual_Flow_Form form) { Component next; if (currentObj.need_to_decrease_scope) { Runtime.Decrease_Scope(); currentObj.need_to_decrease_scope = false; if (parse_tree_pkg.did_function_call) { if (Runtime.method_return_value != null) { currentObj.values.Add(Runtime.method_return_value); } Runtime.method_return_value = null; } } while (currentObj.number_method_expressions_run < currentObj.method_expressions.Count) { CallStack.Push(currentObj, (Subchart)form.running_tab); Step_Helpers.Set_State_Entering(); bool b = interpreter_pkg.run_expon( currentObj.method_expressions[currentObj.number_method_expressions_run] as parse_tree.expon, currentObj.Text, currentObj); currentObj.number_method_expressions_run++; if (b) { currentObj.need_to_decrease_scope = true; form.Possible_Tab_Update(form.running_tab); form.currentObj = ((Subchart)form.running_tab).Start; form.currentObj.running = true; return(form.currentObj); } else { CallStack.Pop(); } } if (currentObj.Name == "Oval") { if (currentObj.Successor != null) { next = currentObj.Successor.First_Of(); next.reset_this_method_expressions_run(); return(next); } else { return(null); } } else if (currentObj.Name == "Return") { numbers.value v = interpreter_pkg.run_return_value(currentObj.parse_tree, currentObj.Text); Runtime.method_return_value = v; return(null); } else if (currentObj.Name == "Rectangle") { // when running belownormal, upgrade priority to close graphics window if (currentObj.Text.ToLower() == "close_graph_window") { System.Threading.ThreadPriority p = System.Threading.Thread.CurrentThread.Priority; System.Threading.Thread.CurrentThread.Priority = System.Threading.ThreadPriority.AboveNormal; interpreter_pkg.run_assignment(currentObj.parse_tree, currentObj.Text); System.Threading.Thread.CurrentThread.Priority = p; } else { interpreter_pkg.run_assignment(currentObj.parse_tree, currentObj.Text); } next = Find_Successor(currentObj); next.reset_this_method_expressions_run(); return(next); } else if (currentObj.Name == "IF_Control") { bool choice = interpreter_pkg.run_boolean( currentObj.parse_tree, currentObj.Text); if (choice == true) { // go to left child if possible, otherwise // go to the successor of the if if (((IF_Control)currentObj).yes_child != null) { next = ((IF_Control)currentObj). yes_child.First_Of(); next.reset_this_method_expressions_run(); return(next); } else { next = Find_Successor(currentObj); next.reset_this_method_expressions_run(); return(next); } } else { if (((IF_Control)currentObj).no_child != null) { next = ((IF_Control)currentObj). no_child.First_Of(); next.reset_this_method_expressions_run(); return(next); } else { next = Find_Successor(currentObj); next.reset_this_method_expressions_run(); return(next); } } } else if (currentObj.Name == "Parallelogram") { if (((Parallelogram)currentObj).is_input) { interpreter_pkg.run_input(currentObj.parse_tree, currentObj.Text, ((Parallelogram)currentObj).prompt, ((Parallelogram)currentObj).input_is_expression, ((Parallelogram)currentObj).prompt_tree); } else { interpreter_pkg.run_output(currentObj.parse_tree, currentObj.Text); } next = Find_Successor(currentObj); next.reset_this_method_expressions_run(); return(next); } else if ((currentObj.Name == "Loop") && (((Loop)currentObj).light_head)) { ((Loop)currentObj).light_head = false; if (((Loop)currentObj).before_Child != null) { next = ((Loop)currentObj).before_Child.First_Of(); next.reset_this_method_expressions_run(); return(next); } else { return(currentObj); } } else if (currentObj.Name == "Loop") { bool choice = interpreter_pkg.run_boolean( currentObj.parse_tree, currentObj.Text); // keep going on yes if loop logic reversed, no if not if ((!choice && !Component.reverse_loop_logic) || (choice && Component.reverse_loop_logic)) { // on false, go to first of after_child if // we can, otherwise back to the top of the loop! if (((Loop)currentObj).after_Child != null) { next = ((Loop)currentObj).after_Child.First_Of(); next.reset_this_method_expressions_run(); return(next); } else { next = currentObj.First_Of(); next.reset_this_method_expressions_run(); return(next); } } else { // on true, go to successor of loop next = Find_Successor(currentObj); next.reset_this_method_expressions_run(); return(next); } } else { throw new System.Exception("unrecognized object: " + currentObj.Name); } }
public ServicePool(System.Threading.ThreadStart callback, int numThreads, string name, System.Threading.ThreadPriority priority) { this.threadDelegate = callback; this.threads = new System.Threading.Thread[numThreads]; this.runnning = numThreads; for (int i = 0; i <= this.threads.Length - 1; i++) { var th = new System.Threading.Thread(this.Execute); th.Name = string.Concat(name, " #", i + 1); th.Priority = priority; th.Start(); this.threads[i] = th; } }
internal static void DecodeGif(int taskId, string filepath, int framesToRead, System.Threading.ThreadPriority workerPriority, DecodeCompleteCallback completeCallback) { var gifMetaHolderHandle = GCHandle.Alloc(new GifMetadata(), GCHandleType.Pinned); DecodeTasks[taskId] = new GifDecodeResources() { gifMetadataHandle = gifMetaHolderHandle, completeCallback = completeCallback }; C.EM_DecodeGif(taskId, filepath, framesToRead, EncodeThreadPriority(workerPriority), gifMetaHolderHandle.AddrOfPinnedObject(), GetFrameMetadataHolderFunc, GetImageDataHolderFunc, GifDecodingCompleteCallback); }