/// <summary> /// Handles the SetCompleted event of the m_gate control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="DCalcCore.Utilities.QueueEventArgs"/> instance containing the event data.</param> private void m_gate_SetCompleted(Object sender, QueueEventArgs e) { /* Forward the set to the user */ if (QueuedWorkCompleted != null) { QueuedWorkCompleted(this, new ScriptQueueEventArgs((IScript)sender, e.OutputSet, e.SetId)); } }
/// <summary> /// Work Queue thread method. /// </summary> private void WorkQueueMethod() { try { while (true) { QueueEventArgs eventArgs = null; WorkQueueItem nextItem = null; Boolean shouldSleep = false; lock (m_SyncRoot) { nextItem = GetNext(); if (nextItem != null) { ScalarSet outSet = null; if (!nextItem.Cancelled) { try { outSet = nextItem.CompiledScript.Execute(nextItem.InputSet); } catch { } eventArgs = new QueueEventArgs(outSet, nextItem.InputSet.Id); } } else shouldSleep = true; } if (shouldSleep) Thread.Sleep(10); /* Sleep 10ms if there's nothing to work on */ else if (eventArgs != null) { if (QueuedWorkCompleted != null) { QueuedWorkCompleted(nextItem.Script, eventArgs); } } } } catch { return; } }