public static bool Exists(Type type) { ChoGuard.ArgumentNotNull(type, "Type"); return(Exists(type, null)); }
/// <summary> /// Creates instances for all performance counter members in the given type. /// </summary>q /// <remarks> /// The type must have the PerformanceCounterCategory attribute set. Each performance counter /// member must be static and tagged with a PerformanceCounter attribute. /// </remarks> /// <param name="type">Type to instantiate counters</param> /// <returns><b>True</b> if counters were created successfully, <b>false</b> otherwise.</returns> public static bool CreateCounters(Type type) { ChoGuard.ArgumentNotNull(type, "Type"); return(CreateCounters(type, null)); }
public static bool CreateCounters(object instance) { ChoGuard.ArgumentNotNull(instance, "Instance"); return(CreateCounters(instance.GetType(), instance)); }
public static ChoDictionary <TKey, TValue> ReadOnly(ChoDictionary <TKey, TValue> dictionary) { ChoGuard.ArgumentNotNull(dictionary, "Dictionary"); return(new ChoReadOnlyDictionary <TKey, TValue>(dictionary)); }
private void Stop(bool silent) { if (ChoGuard.IsDisposed(this)) { return; } _stoppingService = true; //if (!silent) // CheckState(); lock (_padLock) { if (_queueProcessingThread != null) { _queue.Enqueue(_shutdownMsg); int noOfRetry = 0; while (true) { //Enqueue(_endOfMsg); if (ChoTrace.ChoSwitch.TraceVerbose) { Trace.WriteLine("{0}: Stopping thread...".FormatString(_name)); } if (_queueProcessingThread == null || !_queueProcessingThread.IsAlive || _queueProcessingThread.Join(1000)) { if (ChoTrace.ChoSwitch.TraceVerbose) { Trace.WriteLine("{0}: Stopped thread...".FormatString(_name)); } _queueProcessingThread = null; //_stoppingService = false; break; } else { Thread.Sleep(10); } noOfRetry++; if (noOfRetry >= 5) { Trace.WriteLine("{0}: Aborting thread...".FormatString(_name)); try { _queueProcessingThread.AbortThread(); } catch (Exception ex) { Trace.WriteLine(ex.ToString()); } break; } } if (_queueProcessingThread != null && !_queueProcessingThread.IsAlive) { _queueProcessingThread = null; } } } }
public int Send(string value) { ChoGuard.ArgumentNotNullOrEmpty(value, "value"); return(Send(ConvertToBytes(new ChoNetMessage(value)))); }
public static ChoDictionary <TKey, TValue> Fixed(ChoDictionary <TKey, TValue> dictionary) { ChoGuard.ArgumentNotNull(dictionary, "Dictionary"); return(new ChoFixedDictionary <TKey, TValue>(dictionary)); }
void ICollection <KeyValuePair <TKey, TValue> > .Add(KeyValuePair <TKey, TValue> item) { ChoGuard.ArgumentNotNull(item, "Item"); Add(item.Key, item.Value); }
bool ICollection <KeyValuePair <TKey, TValue> > .Contains(KeyValuePair <TKey, TValue> item) { ChoGuard.ArgumentNotNull(item, "Item"); return(ContainsKey(item.Key) && ContainsValue(item.Value)); }
public static ChoQueue <T> Synchronized(ChoQueue <T> queue) { ChoGuard.ArgumentNotNull(queue, "Queue"); return(new ChoQueue <T> .ChoSyncronizedQueue <T>(queue)); }
public static ChoQueue <T> BlockingQueue(ChoQueue <T> queue) { ChoGuard.ArgumentNotNull(queue, "Queue"); return(new ChoQueue <T> .ChoBlockingQueue <T>(queue)); }
public int Send(string value) { ChoGuard.ArgumentNotNullOrEmpty(value, "value"); return(Send(ConvertToBytes(new ChoScalarObject(value)))); }
public int Send(byte[] value) { ChoGuard.ArgumentNotNullOrEmpty(value, "Value"); return(_serverSocket.Send(value, value.Length, _serverEndPoint)); }
public ChoTaggedDescriptionAttribute(string tag, string description) : base(description) { ChoGuard.ArgumentNotNullOrEmpty(tag, "Tag"); _tag = tag; }
public static bool Exists(object instance) { ChoGuard.ArgumentNotNull(instance, "Instance"); return(Exists(instance.GetType(), instance)); }
bool ICollection <KeyValuePair <TKey, TValue> > .Remove(KeyValuePair <TKey, TValue> item) { ChoGuard.ArgumentNotNull(item, "Item"); return(Remove(item.Key)); }
public override bool MoveNext() { ChoGuard.NotDisposed(this); while (true) { if (_enumerator != null) { if (!_enumerator.MoveNext()) { if (_currentIteration == _maxNoOfIteration) { return(false); } else { _currentIteration++; } _enumerator = _enumerable.GetEnumerator(); continue; } if (_match(_enumerator.Current)) { return(true); } } else { if (_listCount == 0) { return(false); } if (_currentIndex == _listCount - 1 || _count != ChoListEnumeratorConst.DefaultCount && _counter == _count) { if (_currentIteration == _maxNoOfIteration) { return(false); } else { _currentIteration++; } _currentIndex = -1; _counter = 0; continue; } else { _currentIndex++; } if (_currentIndex < _startIndex) { continue; } if (_match(Current)) { if (_count != ChoListEnumeratorConst.DefaultCount) { _counter++; } return(true); } } } }
public void Start(ChoConsolePercentageProgressorStart consolePercentageProgressorStart, ChoAbortableAsyncCallback callback, object state, int timeout) { if (ChoApplication.ApplicationMode != ChoApplicationMode.Console) { return; } ChoGuard.NotDisposed(this); //if (_isStarted) return; int isStarted = Interlocked.CompareExchange(ref _isStarted, 1, 0); if (isStarted == 1) { return; } Interlocked.CompareExchange(ref _stopRequested, 0, 1); lock (ChoConsole.SyncRoot) { ChoConsole.Clear(); ChoConsole.ClearKeys(); IChoAsyncResult result = ChoConsole.OutputQueuedExecutionService.Enqueue(() => { _location = WriteNSavePosition(_msg + " "); _statusMsgLocation = new ChoPoint(_consolePercentageProgressorSettings.ProgressBarMarginX, _location.Y + 1); WritePercentage("[0%]"); }); result.AsyncWaitHandle.WaitOne(); SetPercentageComplete(MinPercentage); } Action <ChoConsolePercentageProgressor, int> wrappedFunc = delegate { _threadToKill = Thread.CurrentThread; try { int percentage = MinPercentage; int retPercentage = MinPercentage; while (retPercentage < MaxPercentage) { if (_stopRequested == 1) { break; } retPercentage = consolePercentageProgressorStart(this, percentage, state); if (percentage >= retPercentage) { throw new ChoConsoleException("Returned percentage '{0}' value <= running percentage '{1}' value. It may leads to infinite loop.".FormatString(retPercentage, percentage)); } else { percentage = retPercentage; } lock (ChoConsole.SyncRoot) { SetPercentageComplete(retPercentage); } } } catch (ThreadAbortException) { Thread.ResetAbort(); } }; //try //{ // ChoAPM.InvokeMethod(wrappedFunc, new object[] { this, MinPercentage }, timeout); //} //catch (Exception ex) //{ // ErrorOccured(this, new ChoExceptionEventArgs(ex)); //} _result = ChoAbortableQueuedExecutionService.Global.Enqueue <ChoConsolePercentageProgressor, int>(wrappedFunc, this, MinPercentage, callback, state, timeout); }