foreach (Node node in nodes) { try { ParameterizedThreadStart ths = new ParameterizedThreadStart(StartTh); Thread th = new Thread(ths); th.Priority = ThreadPriority.Highest; th.Name = node .nodeid.ToString(); th.Start(node ); } catch (ThreadStartException ex) { MessageBox.Show(ex.Message); } catch (ThreadInterruptedException ex) { MessageBox.Show(ex.Message); } } void StartTh(object values) { Node node = (Node)values; foreach (Node child in node.childs) { listBox1.Items.Add("Nodeid :" + node.nodeid + " -> " + sendMesg(child)); } } private string sendMesg(Node child) { string rslt= ""; lock (this) { try { if (!hashtable.ContainsKey(child.nodeid)) { hashtable.Add(child.nodeid, child.energy); Monitor.Wait(this); } Monitor.Pulse(this); hashtable.Remove(child.nodeid); rslt = child.nodeid.ToString(); } catch (ThreadStartException ex) { MessageBox.Show(ex.Message); } catch (ThreadInterruptedException ex) { MessageBox.Show(ex.Message); } } return rslt; }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)