public override void Execute() { Packet p = _inp.Receive(); string name = p.Content.ToString(); _outp.Send(p); _inp.Close(); DirectoryInfo di = new DirectoryInfo(name); DirectoryInfo[] dirs = di.GetDirectories(); if (dirs.Length == 0) { FlowError.Complain("Missing directory"); } foreach (DirectoryInfo d in dirs) { _outpd.Send(Create(d.FullName)); } FileInfo[] files = di.GetFiles(); foreach (FileInfo f in files) { _outpf.Send(Create(f.FullName)); } }
public override void Execute() { Packet p = _inPort.Receive(); Mas.Rpc.Climate.ITimeSeries timeSeries = null; if (p != null) { timeSeries = p.Content as Mas.Rpc.Climate.ITimeSeries; Drop(p); _inPort.Close(); } if (timeSeries != null) { try { var header = timeSeries.Header().Result; var hl = header.Select(h => h.ToString()).ToList(); p = Create(hl); _outPort.Send(p); timeSeries.Dispose(); } catch (RpcException e) { Console.WriteLine(e.Message); } } }
public override void Execute() { Packet p = _keyPort.Receive(); if (p != null) { _key = p.Content?.ToString() ?? _key; Drop(p); _keyPort.Close(); } p = _inPort.Receive(); if (p != null) { if (p.Type == Packet.Types.Normal && p.Attributes.ContainsKey(_key)) { _valPort.Send(Create(p.Attributes[_key])); } if (_outPort.IsConnected()) { _outPort.Send(p); } else { Drop(p); } } }
public override void Execute() /* throws Throwable */ { Packet p = _inport.Receive(); _outport.Send(p); _inport.Close(); }
public override void Execute() { Packet p; if (null != (p = _cfgp.Receive())) { string param = p.Content.ToString(); string[] words = param.Split(','); _wordoff = Int32.Parse(words[0]); _linlen = Int32.Parse(words[1]); Drop(p); _cfgp.Close(); } p = _inp.Receive(); string word = p.Content.ToString(); string text = p.Attributes["Text"] as string; text = new string(' ', _linlen) + text + new string(' ', _linlen); int offset = (int)p.Attributes["Offset"]; int i = offset + _linlen - _wordoff; int j = text.Length - i; j = j < _linlen ? j : _linlen; string line = text.Substring(i, j); line = line.Substring(0, _wordoff) + "*" + line.Substring(_wordoff); _outp.Send(Create(line)); Drop(p); }
public override void Execute() { Packet p = _cfgp.Receive(); if (p != null) { string param = p.Content.ToString(); _timeout = Double.Parse(param); Drop(p); _cfgp.Close(); } Packet p0 = _inp.Receive(); string path = p0.Content as string; if (path != null) { TextReader tr = new StreamReader(path); string blob = ReadBlobItem(tr); p = Create(blob); p.Attributes.Add("Path", path); _outp.Send(p); } Drop(p0); }
public override void Execute() { Packet p = _sturdyRefPort.Receive(); if (p != null) { _sturdyRef = p.Content.ToString(); Drop(p); _sturdyRefPort.Close(); } try { if (ConMan() == null) { return; } using var timeSeries = ConMan().Connect <Mas.Rpc.Climate.ITimeSeries>(_sturdyRef).Result; //var header = timeSeries.Header().Result; //var hl = header.Select(h => h.ToString()).ToList(); //Console.WriteLine(hl.Aggregate((a, v) => a + " | " + v)); //p = Create(hl); p = Create(Capnp.Rpc.Proxy.Share(timeSeries)); _outPort.Send(p); } catch (RpcException e) { Console.WriteLine(e.Message); } }
public override void Execute() /* throws Throwable */ { Packet ctp = _count.Receive(); string param = ctp.Content.ToString(); Int32 ct = Int32.Parse(param); Drop(ctp); _count.Close(); Packet p = Create(Packet.Types.Open, ""); _outport.Send(p); for (int i = 0; i < ct; i++) { if (i % 20 == 4) { p = Create(Packet.Types.Close, ""); _outport.Send(p); p = Create(Packet.Types.Open, ""); _outport.Send(p); } int j = 100 - i; string s = String.Format("{0:d4}", j) + " abc"; p = Create(s); _outport.Send(p); } p = Create(Packet.Types.Close, ""); _outport.Send(p); // output.close(); // terminate(); }
public override void Execute() { Packet p = _keyPort.Receive(); if (p != null) { _key = p.Content?.ToString() ?? _key; Drop(p); _keyPort.Close(); } object val = null; if ((p = _valPort.Receive()) != null) { val = p.Content; Drop(p); } if ((p = _inPort.Receive()) != null) { if (p.Type == Packet.Types.Normal) { p.Attributes[_key] = val; } _outPort.Send(p); } }
public override void Execute() { Regex regex = null; Packet p = _cfgp.Receive(); string pattern = p.Content.ToString(); try { regex = new Regex(pattern); } catch (Exception) { FlowError.Complain("invalid regular expression " + pattern); } Drop(p); _cfgp.Close(); for (p = _inp.Receive(); p != null; p = _inp.Receive()) { if (regex.IsMatch(p.Content.ToString())) { _outp.Send(p); } else { _outpn.Send(p); } } }
public override void Execute() { Packet p = _cfgp.Receive(); string parms = p.Content as string; Drop(p); _cfgp.Close(); string[] parmArray = parms.Split(','); _dsn = parmArray[0]; _query = parmArray[1]; _table = parmArray[2]; _timeout = Double.Parse(parmArray[3]); OdbcConnection conn = new OdbcConnection(_dsn); OdbcCommand cmd = new OdbcCommand(_query, conn); OdbcDataReader rdr = null; try { conn.Open(); } catch (Exception e) { FlowError.Complain("cannot open connection"); } try { rdr = cmd.ExecuteReader(); } catch (Exception e) { FlowError.Complain("cannot execute query"); } List <string> columns = new List <string>(); for (int i = 0; i < rdr.FieldCount; ++i) { columns.Add(rdr.GetName(i)); } int serialno = 0; while (ReadOdbcRow(rdr)) { Record rec = new Record(_table, columns.ToArray()); for (int i = 0; i < rdr.FieldCount; ++i) { rec[i] = rdr[i]; } p = Create(rec); p.Attributes["SerialNo"] = ++serialno; _outp.Send(p); } // _outp.Close( ); --not needed }
public override void Execute() { Packet p = _keyPort.Receive(); if (p != null) { _key = p.Content?.ToString() ?? _key; Drop(p); _keyPort.Close(); } if ((p = _valPort.Receive()) != null) { _val = p.Content; Drop(p); _valPort.Close(); } if ((p = _methPort.Receive()) != null) { _met = p.Content?.ToString(); Drop(p); _methPort.Close(); } if ((p = _inPort.Receive()) != null) { if (p.Type == Packet.Types.Normal) { if (!string.IsNullOrEmpty(_met)) { var t = _val.GetType(); var m = t.GetMethod(_met); var clone = m.Invoke(_val, null); if (clone != null) { p.Attributes[_key] = clone; } } else { if (_val is System.ValueType vt) { p.Attributes[_key] = vt; } else if (_val is System.ICloneable c) { p.Attributes[_key] = c.Clone(); } } } _outPort.Send(p); } }
public override void Execute() { Packet p = _inPort.Receive(); if (p != null) { var str = p.Content.ToString(); Drop(p); try { var ll = str.Split(',').Select(v => double.Parse(v, CultureInfo.CreateSpecificCulture("en-US"))).ToArray(); _outPort.Send(Create(new LatLonCoord { Lat = ll[0], Lon = ll[1] })); } catch (System.Exception e) { Console.WriteLine("Exception in CreateLatLonCoord receiving []: [" + str + "] Exception: " + e.Message); } } Packet latp = _latPort.Receive(); if (latp == null) { // close also lonPort, because lat/lon have to go together _lonPort.Close(); } else { Packet lonp = _lonPort.Receive(); if (lonp == null) { if (latp != null) { Drop(latp); // lat and lon packets have to go together _latPort.Close(); } } else { var lat = (double)(latp.Content as Newtonsoft.Json.Linq.JValue); Drop(latp); var lon = (double)(lonp.Content as Newtonsoft.Json.Linq.JValue); Drop(lonp); _outPort.Send(Create(new LatLonCoord { Lat = lat, Lon = lon })); //Console.WriteLine("created LLCs: " + _count++); } } }
public override void Execute() { Packet p = _typePort.Receive(); if (p != null) { var str = p.Content.ToString()?.ToUpper(); Drop(p); _typePort.Close(); if (str != null) { if (str == "XML") { _structure = new ST.structure { which = ST.structure.WHICH.Xml } } ; else if (str == "JSON") { _structure = new ST.structure { which = ST.structure.WHICH.Json } } ; else if (str == "NONE") { _structure = new ST.structure { which = ST.structure.WHICH.None } } ; } } p = _inPort.Receive(); if (p != null) { var content = p.Content.ToString(); Drop(p); if (content == null) { return; } var st = new ST() { Structure = _structure, Value = content }; p = Create(st); _outPort.Send(p); } }
public override void Execute() { var p = _iipPort.Receive(); if (p != null) { _iip = p.Content; //send first IIP on self start if (!_initialIIPSent) { _outPort.Send(Create(_iip)); _initialIIPSent = true; } Drop(p); _iipPort.Close(); } p = _truePort.Receive(); if (p != null) { if (p.Content is bool b) { if (b) { _outPort.Send(Create(_iip)); } else { _truePort.Close(); } } Drop(p); } p = _falsePort.Receive(); if (p != null) { if (p.Content is bool b) { if (!b) { _outPort.Send(Create(_iip)); } else { _falsePort.Close(); } } Drop(p); } }
double _timeout = 1.5; // 1.5 secs public override void Execute() /* throws Throwable*/ { Packet p = _cfgp.Receive(); if (p != null) { string param = p.Content.ToString(); _timeout = Double.Parse(param); Drop(p); _cfgp.Close(); } Packet rp = _source.Receive(); _source.Close(); if (rp == null) { return; } Object o = rp.Content; StreamReader sr = null; if (o is String) { String st = (String)o; sr = new StreamReader(st); } else { Stream str = (Stream)o; sr = new StreamReader(str); } Drop(rp); string s; int no = 0; while ((s = ReadLine(sr)) != null) { no++; p = Create(s); _outport.Send(p); } sr.Close(); Console.Out.WriteLine("Number of lines read: {0}", no); }
public override void Execute() { Packet p = _textPort.Receive(); if (p != null) { var c = p.Content?.ToString().ToUpper(); _text = c == "TRUE" || c == "YES"; Drop(p); _textPort.Close(); } if ((p = _inPort.Receive()) != null) { if (p.Content is ST st) { if (_text) { _outPort.Send(Create(st.Value)); } else { switch (st.Structure.which) { case ST.structure.WHICH.Json: var jt = JToken.Parse(st.Value); _outPort.Send(Create(jt)); break; case ST.structure.WHICH.Xml: var xml = XDocument.Parse(st.Value); _outPort.Send(Create(xml)); break; case ST.structure.WHICH.None: _outPort.Send(Create(st.Value)); break; default: _outPort.Send(Create(st.Value)); break; } } } Drop(p); } }
public override void Execute() /*throws Throwable*/ { Packet wp = _destination.Receive(); if (wp == null) { return; } _destination.Close(); Packet p = _cfgp.Receive(); if (p != null) { string param = p.Content.ToString(); _timeout = Double.Parse(param); Drop(p); _cfgp.Close(); } TextBox tb = wp.Content as TextBox; Drop(wp); while ((p = _inport.Receive()) != null) { LongWaitStart(_timeout); //Thread.Sleep(3000); // testing only string line = p.Content as string; if (tb.Multiline) { line += "\r\n"; } DummyMethod dg = delegate() { tb.AppendText(line); }; tb.Invoke(dg); LongWaitEnd(); _outport.Send(p); } // tw.Close(); }
public override void Execute() /* throws Throwable */ { Packet ctp = _count.Receive(); string param = ctp.Content.ToString(); Int32 ct = Int32.Parse(param); Drop(ctp); _count.Close(); for (int i = ct; i > 0; i--) { string s = String.Format("{0:d6}", i) + "abcd"; Packet p = Create(s); _outport.Send(p); } // output.close(); // terminate(); }
public override void Execute() { Packet p = _keyPort.Receive(); if (p != null) { _key = p.Content?.ToString() ?? _key; Drop(p); _keyPort.Close(); } if ((p = _capPort.Receive()) != null) { if (p.Content is Proxy cap) { _cap?.Dispose(); // dispose potentially old capability _cap = cap; } Drop(p); } if ((p = _inPort.Receive()) != null) { if (_cap != null) { var itypes = (from t in _cap.GetType().GetInterfaces() from a in t.CustomAttributes where a.AttributeType == typeof(ProxyAttribute) select t); if (itypes.Any()) { var mi = typeof(Proxy).GetMethod("Share").MakeGenericMethod(new Type[] { itypes.First() }); var o = mi.Invoke(null, new object[] { _cap }); p.Attributes[_key] = o; //_cap.Cast<Proxy>(false); } } //if (_cap != null) p.Attributes[_key] = Proxy.Share(_cap); _outPort.Send(p); } }
public override void Execute() { Packet p = _countPort.Receive(); if (p != null) { _count = Math.Max(0, UInt64.Parse(p.Content.ToString())); Drop(p); _countPort.Close(); } p = _inPort.Receive(); if (p != null && p.Content is Capnp.Rpc.Proxy cap) { Drop(p); for (ulong i = 0; i < _count; i++) { _outPort.Send(Create(Capnp.Rpc.Proxy.Share(cap))); } cap.Dispose(); } }
public override void Execute() { Packet p = _noPort.Receive(); if (p != null) { _ = int.TryParse(p.Content?.ToString(), out _at); Drop(p); _noPort.Close(); } while ((p = _inPort.Receive()) != null) { if (p.Content is IEnumerable <object> e) { if (e.Count() >= _at) { _outPort.Send(Create(e.ElementAt(_at))); } } Drop(p); } }
public override void Execute() { Packet p = _confPort.Receive(); if (p != null) { try { var conf = JObject.Parse(p.Content?.ToString() ?? "{}"); _at = conf["split-at"]?.Value <string>() ?? _at; _addSSBrackets = conf["add-brackets"]?.Value <bool>() ?? _addSSBrackets; _trim = conf["trim"]?.Value <bool>() ?? _trim; } catch (JsonReaderException) { } Drop(p); _confPort.Close(); } while ((p = _inPort.Receive()) != null) { var str = p.Content.ToString(); Drop(p); var strs = str.Split(_at).Select(s => _trim ? s.Trim() : s); if (strs.Count() > 1 && _addSSBrackets) { _outPort.Send(Create(Packet.Types.Open, "")); } foreach (var s in strs) { _outPort.Send(Create(s)); } if (strs.Count() > 1 && _addSSBrackets) { _outPort.Send(Create(Packet.Types.Close, "")); } } }
//UPGRADE_TODO: The equivalent of method java.lang.Runnable.run is not an override method. 'ms-help://MS.VSCC/commoner/redir/redirect.htm?keyword="jlca5065"' // internal void Run() // implement mainline for thread // runs and keeps running as long as there are input ports to read void ThreadMain() { try { if (IsTerminated() || HasError()) { try { Monitor.Exit(_lockObject); } catch (SynchronizationLockException e) { // do nothing - this is OK! } return; } bool componentExecutedAtLeastOnce = false; _status = States.Active; _mother.Trace("{0}: Started", Name); _ = _inputPorts.TryGetValue("*IN", out _autoInput); _ = _outputPorts.TryGetValue("*OUT", out _autoOutput); if (_autoInput != null) { Packet p = _autoInput.Receive(); if (p != null) { Drop(p); } _autoInput.Close(); } InputStates ist = null; //if (SelfStarting) // _autoStarting = true; //else //if componentent has connected non IIP inputports, but is not selfstarting if (!SelfStarting) { try { ist = new InputStates(_inputPorts, this); } catch (ThreadInterruptedException ex) { if (IsTerminated() || HasError()) { // if we are in the TERMINATED or ERROR state we terminated intentionally return; } // otherwise there was an error throw ex; } } while (SelfStarting || _autoStarting || !ist.allDrained || _autoInput != null || ist.allDrained && MustRun || StackSize() > 0) { _autoInput = null; if (_network._deadlock || IsTerminated()) { break; } _packetCount = 0; foreach (IInputPort port in _inputPorts.Values) { if (port is InitializationConnection icx) { icx.Reopen(); } } _mother.Trace("{0}: Activated", Name); try { componentExecutedAtLeastOnce = true; Execute(); // do one activation! } catch (ComponentException e) { _mother.Trace("Component Exception: " + Name + " - " + e.Message); if (e.Message.StartsWith("*")) { string s = e.Message.Substring(1); FlowError.Complain("Component Exception: " + Name + " - " + s); } else { Console.Out.WriteLine("! Component Exception: " + Name + " - " + e.Message); } } _mother.Trace("{0}: Deactivated", Name); if (_packetCount != 0) { _mother.Trace(Name + " deactivated holding " + _packetCount + " packets"); FlowError.Complain(_packetCount + " packets not disposed of during Component activation of " + Name); } foreach (IInputPort port in _inputPorts.Values) { if (port is InitializationConnection icx) { if (!icx.IsClosed()) { FlowError.Complain("Component deactivated with IIP port not closed: " + icx.Name); } } } MustRun = false; SelfStarting = false; if (_autoStarting) { break; } // lock ((_inputPorts as ICollection).SyncRoot) //{ try { ist = new InputStates(_inputPorts, this); } catch (ThreadInterruptedException ex) { if (IsTerminated() || HasError()) { // if we are in the TERMINATED or ERROR state we terminated intentionally return; } // otherwise there was an error throw ex; } if (ist.allDrained) { break; } //if (_network._deadlock) //{ // break; // } } // while (!ist.allDrained); //_compLog.Trace("{0}: Terminating", Name); //} // catch (System.Exception t) // { //Console.Out.WriteLine("*** Exception detected in " + Name); // System.Diagnostics.Trace.Fail("*** Exception detected in " + Name + ": " + t.Message); // } //_compLog.Trace("{0}: Terminated", Name); if (_autoOutput != null) { //Packet p = Create(""); //_autoOutput.Send(p); _autoOutput.Close(); } _status = States.Terminated; if (_stack.Count > 0) { FlowError.Complain("Stack not empty at component termination: " + Name); } foreach (IInputPort port in _inputPorts.Values) { if (port is Connection cx) { if (cx.Count() > 0) { Console.Out.WriteLine("{0}: Component terminated with {1} packets in input connection", cx.Name, cx.Count()); } while (cx.Count() > 0) { Packet p = cx._buffer.Take(); Console.Out.WriteLine(p); } } else if (port is InitializationConnection iip) { if (componentExecutedAtLeastOnce && !iip.IsClosed()) { FlowError.Complain("Component terminated with input port not closed: " + iip.Name); } } } foreach (OutputPort port in _outputPorts.Values) { port.Close(); } //_status = States.Terminated; //will not be set if never activated //_network.NotifyTerminated(); _mother.NotifyTerminated(this); } catch (Exception e) { // don't tell the mother if we are already in the ERROR or TERMINATE state // because then the mother told us to terminate if (!HasError() && !IsTerminated()) { // an error occurred in this component _status = States.Error; // tell the mother _mother.SignalError(e); } } }
public override void Execute() /*throws Throwable*/ { Packet wp = _destination.Receive(); if (wp == null) { FlowError.Complain("Destination not specified: " + Name); } _destination.Close(); Packet fp = _flush.Receive(); if (fp != null) { Drop(fp); } _flush.Close(); Packet p = _cfgp.Receive(); if (p != null) { string param = p.Content.ToString(); _timeout = Double.Parse(param); Drop(p); _cfgp.Close(); } Object dest = wp.Content; TextWriter tw; if (dest is TextWriter) { tw = dest as TextWriter; } else if (dest is string) { tw = new StreamWriter(dest as string); } else if (dest is Stream) { tw = new StreamWriter(dest as Stream); } else { tw = new StringWriter(); } Drop(wp); while ((p = _inport.Receive()) != null) { //using (TimeoutHandler t = new TimeoutHandler(_timeout, this)) //{ LongWaitStart(_timeout); //Thread.Sleep(3000); // testing only if (p.Type == Packet.Types.Open) { tw.WriteLine("==> Open Bracket"); } else if (p.Type == Packet.Types.Close) { tw.WriteLine("==> Close Bracket"); } else if (p.Content == null) { tw.WriteLine("null"); } else { tw.WriteLine(p.Content); } //} LongWaitEnd(); // sw.Write(linesep); if (fp != null) { string s = (string)fp.Content; if (!(s.Equals("-"))) { tw.Flush(); } } if (_outport.IsConnected()) { _outport.Send(p); } else { Drop(p); } } tw.Close(); }
public override void Execute() /* throws Throwable*/ { int port = 0; string theString; int cyclic_count = 0; Packet p = _port.Receive(); if (p != null) { string portno = p.Content.ToString(); port = Int32.Parse(portno); Drop(p); _port.Close(); } IPAddress localAddr = IPAddress.Parse("127.0.0.1"); TcpListener tcpServerListener = new TcpListener(localAddr, port); tcpServerListener.Start(); TcpClient client = tcpServerListener.AcceptTcpClient(); try { if (client.Connected) { Console.Out.WriteLine("RS Client connected"); //open network stream on accepted socket networkStream = client.GetStream(); streamWriter = new StreamWriter(networkStream); streamReader = new StreamReader(networkStream); } } catch (Exception e) { Console.WriteLine(e.StackTrace); return; } LongWaitStart(_timeout); theString = streamReader.ReadLine(); while (!(theString.Equals("Closedown"))) { LongWaitEnd(); string s = theString.Substring(0, 4); theString = theString.Substring(5); int i = Int32.Parse(s); if (i != cyclic_count) { Console.Error.WriteLine("Sequence error: " + this.Name); break; } //Console.Out.WriteLine("RS read: " + theString); ///* Experimental if (cyclic_count % 20 == 0) { streamWriter.WriteLine(theString); //Console.Out.WriteLine("RS ack: " + theString); streamWriter.Flush(); } //*/ p = Create(theString); _outport.Send(p); LongWaitStart(_timeout); cyclic_count = (cyclic_count + 1) % 10000; theString = streamReader.ReadLine(); } LongWaitEnd(); streamReader.Close(); networkStream.Close(); streamWriter.Close(); client.Close(); Console.WriteLine(this.Name + " Exiting..."); tcpServerListener.Stop(); }
public override void Execute() /*throws Throwable*/ { int port = 0; string theString; Packet p = _port.Receive(); if (p != null) { string portno = p.Content.ToString(); port = Int32.Parse(portno); Drop(p); _port.Close(); } TcpClient tcpClient; try { tcpClient = new TcpClient("localhost", port); } catch { Console.Error.WriteLine( "Failed to connect to server at {0}:{1}", "localhost", port); return; } NetworkStream networkStream = tcpClient.GetStream(); System.IO.StreamReader streamReader = new System.IO.StreamReader(networkStream); System.IO.StreamWriter streamWriter = new System.IO.StreamWriter(networkStream); int cyclic_count = 0; while ((p = _inport.Receive()) != null) { try { string s = String.Format("{0:D4}", cyclic_count); streamWriter.WriteLine(s + ":" + p.Content); //Console.WriteLine("WS write: " + p.Content); streamWriter.Flush(); ///* Experimental //if (cyclic_count % 20 == 0) //{ LongWaitStart(_timeout); theString = streamReader.ReadLine(); //Console.WriteLine("WS ack: " + theString); LongWaitEnd(); // } //*/ } catch { Console.Error.WriteLine("Exception reading from Server"); } if (_outport.IsConnected()) { _outport.Send(p); } else { Drop(p); } cyclic_count = (cyclic_count + 1) % 10000; } streamWriter.WriteLine("Closedown"); Console.WriteLine(this.Name + " Closing"); streamWriter.Flush(); networkStream.Close(); streamReader.Close(); streamWriter.Close(); }
public override void Execute() { Packet p = _cfgp.Receive(); string s = p.Content as string; string[] stArray = s.Split(','); _fldArray = new int[stArray.Length]; for (int i = 0; i < stArray.Length; i++) { stArray[i].Trim(); _fldArray[i] = Int32.Parse(stArray[i]); } Drop(p); _cfgp.Close(); parmct = _fldArray.Length; int totlen = 0; for (int i = 0; i < parmct; i++) { totlen += _fldArray[i]; } for (int i = 0; i < parmct; i++) { Packet p2 = Create(Packet.Types.Open, " "); _outport.Send(p2); } int no = _inportArray.Length; int count = no; // count of not drained input ports pArray = new Packet[no]; for (int i = 0; i < no; i++) { p = _inportArray[i].Receive(); if (p == null) { pArray[i] = null; --count; } else { pArray[i] = p; } } while (true) { hold = "\uffff"; low = 0; for (int i = 0; i < no; i++) { if (pArray[i] != null) { string value = (string)pArray[i].Content; value = value.Substring(0, totlen); if (ordCmp.Compare(value, hold) < 0) { hold = value; low = i; } } } SendOutput(low); pArray[low] = null; p = _inportArray[low].Receive(); if (p == null) { count--; } else { pArray[low] = p; } if (count == 0) { break; } } for (int i = 0; i < parmct; i++) { Packet p2 = Create(Packet.Types.Close, " "); _outport.Send(p2); } }