/// <summary> /// Instantiate a new SuspendedJob instance saving /// the specified job as an IpcMessage to the /// specified IpcMessageRoot. A new InstanceId /// will be assigned. /// </summary> /// <param name="messageRoot"></param> /// <param name="job"></param> public SuspendedJob(IpcMessageRoot messageRoot, Job job) { this.InstanceId = Guid.NewGuid().ToString(); this.IpcMessageRoot = messageRoot; IpcMessage message = messageRoot.GetMessage <Job>(this.InstanceId); message.Write(job); }
private void WriteProperty(Type type, PropertyInfo prop, object propValue, string hash) { DirectoryInfo propRoot = GetPropertyDirectory(type, prop); int version = GetNextVersionNumber(propRoot, prop, hash); string writeToRootDir = Path.Combine(propRoot.FullName, hash); IpcMessage msg = IpcMessage.Get(version.ToString(), prop.PropertyType, writeToRootDir); msg.Write(propValue); }
private void TryWrite(IpcMessage message, object data, int retriedCount = 0, ILogger logger = null) { try { message.Write(data); } catch (Exception ex) { if (retriedCount < MaxRetries) { TryWrite(message, data, ++retriedCount, logger); } else { Message = ex.Message; (logger ?? Log.Default).AddEntry("Failed to write IpcMessage: {0}", ex, ex.Message); FireEvent(WriteObjectFailed, EventArgs.Empty); } } }
public void StartMessaging() { if (IpcMessage.Exists <TestMessage>(messageName)) { IpcMessage.Delete(messageName, typeof(TestMessage)); } IpcMessage msg = IpcMessage.Create <TestMessage>(messageName); Timer timer = new Timer((o) => { TestMessage message = new TestMessage(); message.Name = "Name_".RandomLetters(4); message.IsMonkey = RandomHelper.Bool(); OutLineFormat("Setting data to:\r\n {0}", ConsoleColor.Cyan, message.PropertiesToString()); msg.Write(message); }, null, 0, 1000); Pause(); }