protected Command(String Name)
 {
     Arguments = new Queue<string>();
     Header = new MessageHeader
     {
         Name = Name,
         Type = MessageType.Command,
         Client = "Client",
         ProcID = "123456",
         InvokeID = "Invo",
         NumberOfSegments = Arguments.Count
     };
     Finished = new ManualResetEvent(false);
 }
 public static MessageHeader FromString(String headerText)
 {
     MessageHeader result = null;
     Match match = Regex.Match(headerText, @"(?<Name>[A-Za-z\s]{20})(?<Type>[CDPRN])(?<Client>[A-Za-z\s]{20})(?<Proc>[\w\s]{6})(?<Invoke>[\w\s]{4})(?<Seg>[0-9\s]{4})");
     if (match.Success)
     {
         result = new MessageHeader();
         if (match.Groups["Name"].Success)
             result.Name = match.Groups["Name"].Value.Trim();
         if (match.Groups["Type"].Success)
             result.Type = (MessageType)((int)match.Groups["Type"].Value[0]);
         if (match.Groups["Client"].Success)
             result.Client = match.Groups["Client"].Value.Trim();
         if (match.Groups["Proc"].Success)
             result.ProcID = match.Groups["Proc"].Value.Trim();
         if (match.Groups["Invoke"].Success)
             result.InvokeID = match.Groups["Invoke"].Value.Trim();
         if (match.Groups["Seg"].Success)
             result.NumberOfSegments = int.Parse(match.Groups["Seg"].Value.Trim());
     }
     return result;
 }