public override void Initialize(IEventSource eventSource)
{
if (eventSource == null) {
return;
}
var p = Parameters.Split(';');
if (p.Length < 2) {
throw new Exception("Requires at least pipeName and guid");
}
var pipeName = p[0];
var iid = new Guid(p[1]);
_client = new RpcClientApi(iid, RpcProtseq.ncacn_np, null, pipeName);
messagePump = Task.Factory.StartNew(() => {
try {
BuildMessage msg;
while (!stop || _messages.Count > 0) {
if (_messages.TryDequeue(out msg)) {
var result = _client.Execute(msg.ToByteArray());
if (result.Length > 0 && result[1] == 0x01) {
// we've been asked to kill ourselves.
stop = true;
}
continue;
}
Thread.Sleep(5);
}
}
finally {
stop = true;
}
});
eventSource.BuildFinished += eventSource_BuildFinished;
eventSource.BuildStarted += eventSource_BuildStarted;
eventSource.CustomEventRaised += eventSource_CustomEventRaised;
eventSource.ErrorRaised += eventSource_ErrorRaised;
eventSource.MessageRaised += eventSource_MessageRaised;
eventSource.ProjectFinished += eventSource_ProjectFinished;
eventSource.ProjectStarted += eventSource_ProjectStarted;
//eventSource.StatusEventRaised += eventSource_StatusEventRaised;
eventSource.TargetFinished += eventSource_TargetFinished;
eventSource.TargetStarted += eventSource_TargetStarted;
eventSource.TaskFinished += eventSource_TaskFinished;
eventSource.TaskStarted += eventSource_TaskStarted;
eventSource.WarningRaised += eventSource_WarningRaised;
}