How about something like this? Note I didn't make any attempt to compile this.
You have to copy over all the properties of the Process and transmit them over the wire. On the other side, you can get out the properties and their values for display, although you will not have a real Process object.
public struct PropertyValue {
public PropertyValue( string propertyName, string value)
{
this.PropertyName = propertyName;
this.Value = this.value;
}
private PropertyValue( params string[] pv) => PropertyValue(pv[0], pv[1]);
public string PropertyName {get;}
public string Value {get;}
override public string ToString() => this.PropertyName + ":" + this.Value;
public static PropertyValue FromString(string pv) => return new PropertyValue( pv.Split(":"));
}
and then
public string ToString( Process process) {
var msg = new StringBuffer();
foreach (PropertyInfo property in process.GetProperties()) {
var propertyValue = new PropertyValue( property.Name, property.GetValue( process));
msg.Append( ((msg.Length > 0)? ",": "") + propertyValue.ToString());
}
return msg.ToString();
}
public PropertyValue[] FromString( string msg)
{
string[] pvStrings = msg.Split(",");
PropertyValue[] propertyValues = new PropertyValue[pvStrings.Length];
int i = 0;
foreach (string pvString in pvStrings) {
propertyValues[i] = FromString( pvString);
}
return propertyValues;
}
Processobjects and give them the name what do you get from it? AProcessobject that you get fromGetProcesseshas so much more information than just a name..Processobject actually represents a process running on the machine. The same process isn't running on the other machine so how could knowing the name of the process possibly help? That's like me sending you the name of a person in my house and you being able to determine that persons being and weight simply from that. You need to gather all the information you need from theProcessobjects on the source machine and send it ALL. You don't have to sendProcessobjects, just objects that contain the information you need.