internal int WalkDepthFirst(bool fVisible, ProcessItemDelegate processCallback, object callerObject) { ThreadHelper.ThrowIfNotOnUIThread(); // // TODO Need to see what to do if this is a sub project // // Get the node type // Guid nodeGuid; // if (hier.GetGuidProperty(_vsitemid, (int)__VSHPROPID.VSHPROPID_TypeGuid, out nodeGuid) != 0) if (processCallback == null) { return(0); } object newCallerObject; int processReturn = processCallback(this, callerObject, out newCallerObject); if (processReturn != 0) { // Callback says to skip (1) or stop (-1) return(processReturn); } // The process callback can change the caller object. If not we just use the one originally // passed in. if (newCallerObject == null) { newCallerObject = callerObject; } // Walk children if there are any if (IsExpandable()) { VsHierarchyItem child = GetFirstChild(fVisible); while (child != null) { object isNonMemberItemValue = child.GetProperty(__VSHPROPID.VSHPROPID_IsNonMemberItem); // Some project systems (e.g. F#) don't support querying for the VSHPROPID_IsNonMemberItem property. // In that case, we treat this child as belonging to the project bool isMemberOfProject = isNonMemberItemValue == null || (bool)isNonMemberItemValue == false; if (isMemberOfProject) { int returnVal = child.WalkDepthFirst(fVisible, processCallback, newCallerObject); if (returnVal == -1) { return(returnVal); } } child = child.GetNextSibling(fVisible); } } return(0); }
//Here we call a passed-in delegate on each item to process it public void ProcessCheapItems(ProcessItemDelegate processItemDelegate, double price) { foreach (Item item in itemList) { if (item.CheckPrice(price)) { //Here we call the delegate processItemDelegate(item); } } }
///<summary> ///Iterates through all the WorkUnits until the producer calls CompleteAdding() and all added WorkUnits have been processed. ///</summary> public void Begin() { // if the external process doesn't set up a process, just pass the value along if (ProcessCompleted.GetInvocationList().Count() == 0 && PassValuesIfNoProcessDelegate) { Process = w => { return(w); }; } Task.Run(() => { InnerWorkLoop(); }); }
private void ProcessSettings(ProcessItemDelegate process) { for (int i = 0; i < treeOptions.Nodes.Count; i++) { TreeNode node = treeOptions.Nodes[i]; IExtension extension = (IExtension)node.Tag; Control[] options = new Control[node.Nodes.Count]; for (int j = 0; j < node.Nodes.Count; j++) { options[j] = (Control)node.Nodes[j].Tag; } process(extension, options); } treeOptions.Nodes.Clear(); }
internal int WalkDepthFirst(bool fVisible, ProcessItemDelegate processCallback, object callerObject) { // // TODO Need to see what to do if this is a sub project // // Get the node type // Guid nodeGuid; // if (hier.GetGuidProperty(_vsitemid, (int)__VSHPROPID.VSHPROPID_TypeGuid, out nodeGuid) != 0) if (processCallback == null) { return(0); } object newCallerObject; int processReturn = processCallback(this, callerObject, out newCallerObject); if (processReturn != 0) { // Callback says to skip (1) or stop (-1) return(processReturn); } // The process callback can change the caller object. If not we just use the one originally // passed in. if (newCallerObject == null) { newCallerObject = callerObject; } // Walk children if there are any if (IsExpandable()) { VsHierarchyItem child = GetFirstChild(fVisible); while (child != null) { int returnVal = child.WalkDepthFirst(fVisible, processCallback, newCallerObject); if (returnVal == -1) { return(returnVal); } child = child.GetNextSibling(fVisible); } } return(0); }
private void ProcessSettings(ProcessItemDelegate process) { for (int i = 0; i < treeOptions.Nodes.Count; i++) { TreeNode node = treeOptions.Nodes[i]; IExtension extension = (IExtension)node.Tag; Control[] options = new Control[node.Nodes.Count]; for (int j = 0; j < node.Nodes.Count; j++) { options[j] = (Control)node.Nodes[j].Tag; } process(extension, options); } treeOptions.Nodes.Clear(); }
private void ProcessSettings(ProcessItemDelegate process) { Hashtable extensionToControlArray = new Hashtable(); for (int i = 0; i < _notebook.NPages; i++) { BaseWidget node = (BaseWidget)_notebook.GetNthPage(i); if (!extensionToControlArray.ContainsKey(node.Extension)) { extensionToControlArray[node.Extension] = new List <BaseWidget>(); } ((List <BaseWidget>)extensionToControlArray[node.Extension]).Add(node); } foreach (object optionsList in extensionToControlArray.Values) { List <BaseWidget> options = (List <BaseWidget>)optionsList; process(options[0].Extension, options.ToArray()); } }
/// <summary> /// Constructs a new WorkerThread /// </summary> /// <param name="item">The callback that performs the work</param> public WorkerThread(ProcessItemDelegate item, bool paused) { m_delegate = item; m_event = new AutoResetEvent(paused); m_terminate = false; m_tasks = new Queue <Tx>(); m_state = paused ? WorkerThread <Tx> .RunState.Paused : WorkerThread <Tx> .RunState.Run; m_thread = new Thread(new ThreadStart(Runner)); try { //The worker is using the same locale as the caller m_thread.CurrentCulture = System.Threading.Thread.CurrentThread.CurrentCulture; m_thread.CurrentUICulture = System.Threading.Thread.CurrentThread.CurrentUICulture; } catch { } m_thread.IsBackground = true; m_thread.Start(); }
public static void Main() { ItemDB itemDB = new ItemDB(); itemDB.AddItem("Chair", 45.67); itemDB.AddItem("Table", 165.80); itemDB.AddItem("Desk", 65.30); itemDB.AddItem(new Item("Laptop", 148.0)); //Console.WriteLine("Items with prices lower than 100 euros:"); //Here we call ProcessCheapItems() method and pass a delegate instance to it string input = ""; double price = 0; bool cont = false; do { try { Console.Write("Please enter a price: "); input = Console.ReadLine(); price = Int16.Parse(input); cont = false; } catch (FormatException) { Console.WriteLine(input + " is not convertible to a number!"); cont = true; } } while (cont); ProcessItemDelegate pid = new ProcessItemDelegate(DisplayName); itemDB.ProcessCheapItems(pid, price); //Here we call ProcessCheapItems() method and pass another delegate instance to it itemDB.ProcessCheapItems(new ProcessItemDelegate(itemDB.DisplayItemInfo), price); Console.WriteLine("Average Item Price: {0:#.##} euros", itemDB.AveragePrice()); Console.ReadLine(); }
public ActionsQueue(IEnumerable <T> collection, ProcessItemDelegate processItemDelegate) : this(processItemDelegate, new Queue <T>(collection)) { }
public ActionsQueue(int capacity, ProcessItemDelegate processItemDelegate) : this(processItemDelegate, new Queue <T>(capacity)) { }
protected ActionsQueue(ProcessItemDelegate processItemDelegate, Queue <T> internalQueue) { _processItemDelegate = processItemDelegate; _internalQueue = internalQueue; _activeExecutions = new List <T>(); }
/// <summary> /// Adds an item to the queue. /// </summary> /// <param name="del">The delegate to enqueue.</param> /// <param name="parameter">The parameter to pass to the delegate when it is executed.</param> public void Enqueue(T parameter, ProcessItemDelegate <T> del) { Enqueue(new ProcessItemCommand <T>(parameter, del)); }
/// <summary> /// Constructor. /// </summary> /// <param name="parameter">The item to pass to <paramref name="del"/></param> /// <param name="del">The delegate to call.</param> public ProcessItemCommand(T parameter, ProcessItemDelegate <T> del) { _parameter = parameter; _del = del; }
public static void Main() { ItemDB itemDB = new ItemDB(); itemDB.AddItem("Chair", 45.67); itemDB.AddItem("Table", 165.80); itemDB.AddItem("Desk", 65.30); itemDB.AddItem(new Item("Laptop", 148.0)); Console.WriteLine("Items with prices lower than 100 euros:"); // Here we call ProcessCheapItems() method and pass a delegate instance to it double price; Console.Write("Please enter a price: "); price = Int16.Parse(Console.ReadLine()); ProcessItemDelegate pid = new ProcessItemDelegate(DisplayName); itemDB.ProcessCheapItems(pid, price); // Here we call ProcessCheapItems() method and pass another delegate instance to it itemDB.ProcessCheapItems(new ProcessItemDelegate(itemDB.DisplayItemInfo), price); Console.WriteLine("Average Item Price: {0:#.##} euros", itemDB.AveragePrice()); }
// Here we call a passed-in delegate on each item to process it public void ProcessCheapItems(ProcessItemDelegate processItemDelegate, double price) { foreach (Item item in itemList) { if (item.CheckPrice(price)) // Here we call the delegate processItemDelegate(item); } }
public BlockingThreadPool(IBlockingEnumerator <T> blockingEnumerator, ProcessItemDelegate <T> processItem) { _blockingEnumerator = blockingEnumerator; _processItem = processItem; }
public ActionsQueue(ProcessItemDelegate processItemDelegate) : this(processItemDelegate, new Queue <T>()) { }