private void symbolResolver_OnParserProgress(object sender, ParserProgressEventArgs e) { using (lockObject.Lock()) { serializedEventArgs.Add(new ParserProgressEventArgsXml(e)); } }
public static void LockSet(this IManagedLockObject lockObject, Action setter) { using (lockObject.Lock()) { setter(); } }
public static LoggerConfiguration Relay(this LoggerSinkConfiguration sinkConfiguration, ILoggerRelay loggerRelay, IConfigurationSection serilogConfig, CancellationToken cancellationToken) { LoggerRelayEventSink eventSink; var comparer = new ObjectHashCodeComparer <IConfiguration>(); var configurationTree = new ObjectTree <IConfiguration>(comparer); IConfigurationSection relayConfigurationSection; ObjectTreeItem <IConfiguration> treeItem; LinkedListNode <ObjectTreeItem <IConfiguration> > sibling; LoggerRelayEventSinkConfigArgs logRelayEventSinkConfigArgs = null; configurationTree.AddChild(serilogConfig); serilogConfig.GetDescendantsWithParent(s => s.GetChildren(), (parent, child) => { var parentItem = configurationTree.FindTreeItem(parent); parentItem.AddChild(child); }); relayConfigurationSection = configurationTree.GetDescendants().Select(d => d.InternalObject).OfType <IConfigurationSection>().SingleOrDefault(s => s.Path.RegexIsMatch(@"Serilog:WriteTo:(\d+:)?Name") && s.Value == "Relay"); if (relayConfigurationSection == null) { throw new ConfigurationException("Logger relay requires a configuration section with a RootPath member"); } else { treeItem = configurationTree.FindTreeItem(relayConfigurationSection); sibling = CompareExtensions.GetNonNull(treeItem.LinkedListNode.Next, treeItem.LinkedListNode.Previous); if (sibling != null && ((IConfigurationSection)sibling.Value.InternalObject).Key == "Args") { logRelayEventSinkConfigArgs = sibling.Value.InternalObject.Get <LoggerRelayEventSinkConfigArgs>(); } else { throw new ConfigurationException("Logger relay requires a configuration section with a RootPath member"); } loggerRelay.Initialize(logRelayEventSinkConfigArgs); } using (lockObject.Lock()) { if (eventSinks.Any(s => s.Domain == loggerRelay.Domain)) { eventSink = eventSinks.Single(s => s.Domain == loggerRelay.Domain); } else { eventSink = new LoggerRelayEventSink(loggerRelay, cancellationToken, logRelayEventSinkConfigArgs); eventSinks.Add(eventSink); } } return(sinkConfiguration.Sink(eventSink)); }
private void FileSystemWatcher_Deleted(object sender, FileSystemEventArgs e) { using (lockObject.Lock()) { update = true; } }
public ConsoleTimer(string name) { this.Name = name; using (var _lock = lockObject.Lock()) { timers.Add(this); } }
public static T LockGet <T>(this IManagedLockObject lockObject, Func <T> getter) { T value; using (lockObject.Lock()) { value = getter(); } return(value); }
public static LoggerConfiguration Trace(this LoggerSinkConfiguration sinkConfiguration, string ipAddress, int port, IConfigurationSection serilogConfig, CancellationToken cancellationToken) { TraceLogEventSink eventSink; var comparer = new ObjectHashCodeComparer <IConfiguration>(); var configurationTree = new ObjectTree <IConfiguration>(comparer); IConfigurationSection traceConfigurationSection; ObjectTreeItem <IConfiguration> treeItem; LinkedListNode <ObjectTreeItem <IConfiguration> > sibling; TraceLogEventSinkConfigArgs traceLogEventSinkConfigArgs = null; configurationTree.AddChild(serilogConfig); serilogConfig.GetDescendantsWithParent(s => s.GetChildren(), (parent, child) => { var parentItem = configurationTree.FindTreeItem(parent); parentItem.AddChild(child); }); traceConfigurationSection = configurationTree.GetDescendants().Select(d => d.InternalObject).OfType <IConfigurationSection>().SingleOrDefault(s => s.Path.RegexIsMatch(@"Serilog:WriteTo:(\d+:)?Name") && s.Value == "Trace"); treeItem = configurationTree.FindTreeItem(traceConfigurationSection); sibling = CompareExtensions.GetNonNull(treeItem.LinkedListNode.Next, treeItem.LinkedListNode.Previous); if (sibling != null && ((IConfigurationSection)sibling.Value.InternalObject).Key == "Args") { traceLogEventSinkConfigArgs = sibling.Value.InternalObject.Get <TraceLogEventSinkConfigArgs>(); } using (lockObject.Lock()) { if (eventSinks.Any(s => s.Address == ipAddress && s.Port == port)) { eventSink = eventSinks.Single(s => s.Address == ipAddress && s.Port == port); } else { eventSink = new TraceLogEventSink(ipAddress, port, cancellationToken, traceLogEventSinkConfigArgs); eventSinks.Add(eventSink); } } return(sinkConfiguration.Sink(eventSink)); }
public void Start(Action action) { elapsed = false; internalTimer.Elapsed += (sender, e) => { using (lockObject.Lock()) { internalTimer.Stop(); if (!elapsed) { action(); elapsed = true; } } }; internalTimer.Start(); }
protected void Register() { Debug.Assert(!this.IsComponent); uiThread = Thread.CurrentThread; using (lockObject.Lock()) { var crinfo = new OLECRINFO[1]; oleComponentManager = (IOleComponentManager)Package.GetGlobalService(typeof(SOleComponentManager)); queuedActions = new Queue <GlobalCommandTargetAction>(); whenActions = new List <GlobalCommandTargetAction>(); crinfo[0].cbSize = (uint)Marshal.SizeOf(typeof(OLECRINFO)); crinfo[0].grfcrf = (uint)_OLECRF.olecrfNeedIdleTime | (uint)_OLECRF.olecrfNeedPeriodicIdleTime; crinfo[0].grfcadvf = (uint)_OLECADVF.olecadvfModal | (uint)_OLECADVF.olecadvfRedrawOff | (uint)_OLECADVF.olecadvfWarningsOff; crinfo[0].uIdleTimeInterval = 100; var hr = oleComponentManager.FRegisterComponent(this, crinfo, out componentId); if (ErrorHandler.Failed(hr)) { Marshal.ThrowExceptionForHR(hr); } } }
protected IDisposable Lock() { return(lockObject.Lock()); }
public IDisposable Lock() { return(lockObject.Lock()); }
public bool QueueInstallFromCache(string mode, string install, string cachePath, string packagePath) { using (lockObject.Lock()) { if (NO_INSTALL_FROM_CACHE) { return(false); } else { if (!installsFromCacheToProcess.ContainsKey(install)) { var workingInstallFromCache = new PackageWorkingInstallFromCache(mode, install, cachePath, packagePath, packageModules); if (installsFromCacheStatus == null) { installsFromCacheStatus = new PackageInstallsFromCacheStatus("Queueing installs from cache"); } if (!workingInstallFromCache.IsMissingPeer) { workingInstallFromCache.OnUpdateCacheStatus += WorkingInstallFromCache_OnUpdateCacheStatus; workingInstallFromCache.OnAddInstallStatus += WorkingInstallFromCache_OnAddInstallStatus; this.NothingToPoll = false; this.WriteLineNoLock("Adding '{0}' to install from cache", install); installsFromCacheToProcess.AddToDictionaryIfNotExist(install, workingInstallFromCache); } } } return(true); } }
private IDisposable Lock() { return(lockObject.Lock()); }
public override void DoWork(bool stopping) { using (var client = new HttpClient()) { using (var request = new HttpRequestMessage(new HttpMethod("GET"), url + "/api/Status/GetCacheStatus?mode=Agent")) { try { using (var response = client.SendAsync(request).Result) { var cacheStatus = response.Content.ReadAsAsync <AbstraX.PackageCache.PackageCacheStatus>(); this.lastAttemptedError = string.Empty; OnCacheStatus.Raise(this, cacheStatus.Result); } } catch (Exception ex) { if (ex.Message == "One or more errors occurred.") { this.lastAttemptedError = ex.InnerException.Message; } else { this.lastAttemptedError = ex.Message; } } } } using (var client = new HttpClient()) { using (var request = new HttpRequestMessage(new HttpMethod("GET"), url + "/api/Status/GetInstallFromCacheStatus?mode=Agent")) { try { using (var response = client.SendAsync(request).Result) { var cacheStatus = response.Content.ReadAsAsync <AbstraX.PackageCache.PackageInstallsFromCacheStatus>(); this.lastAttemptedError = string.Empty; OnInstallFromCacheStatus.Raise(this, cacheStatus.Result); } } catch (Exception ex) { if (ex.Message == "One or more errors occurred.") { this.lastAttemptedError = ex.InnerException.Message; } else { this.lastAttemptedError = ex.Message; } } } } using (lockObject.Lock()) { this.lastAttemptedUpdate = DateTime.Now; } }