public ShredHostClientUI() { _shredHostProxy = new ShredHostClient(); _shredCollection = new ShredCollection(); WcfDataShred[] shreds = _shredHostProxy.GetShreds(); foreach (WcfDataShred shred in shreds) { _shredCollection.Add(new Shred(shred._id, shred._name, shred._description, shred._isRunning)); } }
public ShredHostClientUI() { _shredHostProxy = new ShredHostClient(); _shredCollection = new ShredCollection(); WcfDataShred[] shreds = _shredHostProxy.GetShreds(); foreach (WcfDataShred shred in shreds) { _shredCollection.Add(new Shred(shred._id, shred._name, shred._description, shred._isRunning)); } }
public void StopShred(Shred shred) { bool isRunning; using (ShredHostClient client = new ShredHostClient()) { isRunning = client.StopShred(shred.GetWcfDataShred()); } int indexCurrentShred = this.ShredCollection.Items.FindIndex(delegate(Shred otherShred) { return(otherShred.Id == shred.Id); }); this.ShredCollection.Items[indexCurrentShred].IsRunning = isRunning; this.ShredCollection.Items.NotifyItemUpdated(indexCurrentShred); }
private void Refresh() { // poll to see if ShredHost is running ServiceController controller = GetShredHostServiceController(); bool newStatus = (controller.Status == ServiceControllerStatus.Running); if (this.IsShredHostRunning != newStatus) { this.IsShredHostRunning = newStatus; } // if the shred host is not running, the WCF service will not be reachable. if (!this.IsShredHostRunning) { return; } WcfDataShred[] shreds; using (ShredHostClient client = new ShredHostClient()) { shreds = client.GetShreds(); } foreach (WcfDataShred shred in shreds) { int matchIndex = _shredCollection.Items.FindIndex(delegate(Shred otherShred) { return(otherShred.Id == shred._id); }); // this is a new shred being reported from Shred Host, add it to our list, // usually the case if we are refreshing for the first time if (-1 == matchIndex) { _shredCollection.Items.Add(new Shred(shred._id, shred._name, shred._description, shred._isRunning)); } else { if (_shredCollection.Items[matchIndex].IsRunning != shred._isRunning) { _shredCollection.Items[matchIndex].IsRunning = shred._isRunning; } } } }