示例#1
0
 public EventMessage(ExchangeRequestCompletedEventArgs evt, AsyncEvents eventType)
 {
     m_ExchangeRequest = evt.ExchangeRequest;
     m_EventType       = eventType;
     m_Canceled        = evt.Cancelled;
     m_Exception       = evt.Error;
 }
示例#2
0
        public static void StartAsyncWebRequest(string url, Action <ICsqWebResponse> callback, object id = null)
        {
            var request = new CsqWebRequest(url);

            request.Id    = id;
            request.Async = true;

            var mrEvent = request.GetAsync(callback);

            AsyncEvents.Add(mrEvent);
        }
示例#3
0
 internal BadCollector(Stream @out, long tolerance, int collect, int backPressureThreshold, bool skipBadEntriesLogging, Monitor monitor)
 {
     this.@out                   = new PrintStream(@out);
     this._tolerance             = tolerance;
     this._collect               = collect;
     this._backPressureThreshold = backPressureThreshold;
     this._logBadEntries         = !skipBadEntriesLogging;
     this._monitor               = monitor;
     this._logger                = new AsyncEvents <ProblemReporter>(this.processEvent, AsyncEvents.Monitor_Fields.NONE);
     this._eventProcessor        = new Thread(_logger);
     this._eventProcessor.Start();
 }
示例#4
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: public AsyncRequestLog(org.neo4j.io.fs.FileSystemAbstraction fs, java.time.ZoneId logTimeZone, String logFile, long rotationSize, int rotationKeepNumber) throws java.io.IOException
        public AsyncRequestLog(FileSystemAbstraction fs, ZoneId logTimeZone, string logFile, long rotationSize, int rotationKeepNumber)
        {
            NamedThreadFactory threadFactory    = new NamedThreadFactory("HTTP-Log-Rotator", true);
            ExecutorService    rotationExecutor = Executors.newCachedThreadPool(threadFactory);

            _outputSupplier = new RotatingFileOutputStreamSupplier(fs, new File(logFile), rotationSize, 0, rotationKeepNumber, rotationExecutor);
            FormattedLogProvider logProvider = FormattedLogProvider.withZoneId(logTimeZone).toOutputStream(_outputSupplier);

            _asyncLogProcessingExecutor = Executors.newSingleThreadExecutor(new NamedThreadFactory("HTTP-Log-Writer"));
            _asyncEventProcessor        = new AsyncEvents <AsyncLogEvent>(this, this);
            AsyncLogProvider asyncLogProvider = new AsyncLogProvider(_asyncEventProcessor, logProvider);

            _log = asyncLogProvider.GetLog("REQUEST");
        }
示例#5
0
        /// <summary>
        /// Waits until all async events have completed. Use for testing primarily as a web app should not stop normally.
        /// </summary>
        public static void WaitForAsyncEvents(int millisecondsTimeout = -1)
        {
            ManualResetEvent evt;
            int      timeLeft = millisecondsTimeout;
            DateTime start    = DateTime.Now;

            while (AsyncEvents.TryTake(out evt) && timeLeft != 0)
            {
                if (!evt.SafeWaitHandle.IsClosed)
                {
                    evt.WaitOne(timeLeft);
                    if (timeLeft >= 0)
                    {
                        // subtract elapsed time from the total timeout for waiting on all threads
                        timeLeft = Math.Max(0, millisecondsTimeout - (int)(DateTime.Now - start).TotalMilliseconds);
                    }
                }
            }
            DateTime endTime = DateTime.Now;
        }
示例#6
0
        //protected void DoPriorityEvents()
        //{
        //    while(PriorityEvents.Count>0)
        //    {
        //        Async.PostEvent e;
        //        lock (PriorityEvents)
        //        {
        //            e = PriorityEvents.Dequeue();
        //        }
        //        try
        //        {
        //            if (e.PostAction != null)
        //            {
        //                var ret = e.PostAction();
        //                var caw = e.Awaiter as Async.TaskAwaiter;
        //                if(caw!=null)
        //                    caw.SetResult(ret);
        //            }
        //            ExecuteContinue(e.Awaiter);
        //        }
        //        catch (Exception ex)
        //        {
        //            Profiler.Log.WriteException(ex);
        //            e.ExceptionInfo = ex;
        //        }
        //    }
        //}
        protected bool DoOneAsyncEvent(out Async.PostEvent oe)
        {
            oe = null;
            Async.PostEvent e;
            lock (AsyncEvents)
            {
                if (AsyncEvents.Count == 0)
                {
                    return(false);
                }
                e = AsyncEvents.Dequeue();
            }
            try
            {
                var ret = e.PostAction();
                var caw = e.Awaiter as Async.TaskAwaiter;
                caw.SetResult(ret);
            }
            catch (Exception ex)
            {
                Profiler.Log.WriteException(ex);
                e.ExceptionInfo = ex;
                var caw = e.Awaiter as Async.TaskAwaiter;
                caw.SetResult(null);
            }
            if (e.Tag == null)
            {
                if (e.ContinueThread != null)
                {
                    lock (e.ContinueThread.ContinueEvents)
                    {
                        e.ContinueThread.ContinueEvents.Enqueue(e);
                    }
                }
            }

            oe = e;
            return(true);
        }
		public void AddOnReleaseRequestStateAsync (BeginEventHandler beg, EndEventHandler end, object state)
		{
			if (null == _releaseRequestStateAsync)
				_releaseRequestStateAsync = new AsyncEvents ();

			_releaseRequestStateAsync.Add (beg, end, state);
		}
		public void AddOnPreRequestHandlerExecuteAsync (BeginEventHandler beg, EndEventHandler end, object state)
		{
			if (null == _preRequestHandlerExecuteAsync)
				_preRequestHandlerExecuteAsync = new AsyncEvents ();

			_preRequestHandlerExecuteAsync.Add (beg, end, state);
		}
		public void AddOnPostResolveRequestCacheAsync (BeginEventHandler beg, EndEventHandler end, object state)
		{
			if (null == _postResolveRequestCacheAsync)
				_postResolveRequestCacheAsync = new AsyncEvents ();

			_postResolveRequestCacheAsync.Add (beg, end, state);
		}
		public void AddOnEndRequestAsync (BeginEventHandler beg, EndEventHandler end, object state)
		{
			if (null == _endRequestAsync)
				_endRequestAsync = new AsyncEvents ();

			_endRequestAsync.Add (beg, end, state);
		}
		public void AddOnResolveRequestCacheAsync (BeginEventHandler beg, EndEventHandler end)
		{
			if (null == _resolveRequestCacheAsync)
				_resolveRequestCacheAsync = new AsyncEvents ();

			_resolveRequestCacheAsync.Add (beg, end);
		}
 public void AddOnLogRequestAsync(BeginEventHandler beginHandler, EndEventHandler endHandler, object state)
 {
     AsyncEvents.AddHandler(EventLogRequest, beginHandler, endHandler, state, RequestNotification.LogRequest, false, this);
 }
示例#13
0
 internal AsyncLogging(Log metaLog)
 {
     this._metaLog = metaLog;
     this._events  = new AsyncEvents <AsyncLogEvent>(this, this);
 }
		public void AddOnAuthorizeRequestAsync (BeginEventHandler beg, EndEventHandler end)
		{
			if (null == _authorizeRequestAsync)
				_authorizeRequestAsync = new AsyncEvents ();

			_authorizeRequestAsync.Add (beg, end);
		}
示例#15
0
 public EventMessage(OperationStateEventArgs evt, AsyncEvents eventType)
 {
     m_ExchangeRequest = evt.ExchangeRequest;
     m_OperationState  = evt.OperationState;
     m_EventType       = eventType;
 }
 public void AddOnUpdateRequestCacheAsync(BeginEventHandler beginHandler, EndEventHandler endHandler, object state)
 {
     AsyncEvents.AddHandler(EventUpdateRequestCache, beginHandler, endHandler, state, RequestNotification.UpdateRequestCache, false, this);
 }
 public void AddOnReleaseRequestStateAsync(BeginEventHandler beginHandler, EndEventHandler endHandler, object state)
 {
     AsyncEvents.AddHandler(EventReleaseRequestState, beginHandler, endHandler, state, RequestNotification.ReleaseRequestState, false, this);
 }
 public void AddOnPreRequestHandlerExecuteAsync(BeginEventHandler beginHandler, EndEventHandler endHandler, object state)
 {
     AsyncEvents.AddHandler(EventPreRequestHandlerExecute, beginHandler, endHandler, state, RequestNotification.PreExecuteRequestHandler, false, this);
 }
 public void AddOnPostResolveRequestCacheAsync(BeginEventHandler beginHandler, EndEventHandler endHandler, object state)
 {
     AsyncEvents.AddHandler(EventPostResolveRequestCache, beginHandler, endHandler, state, RequestNotification.ResolveRequestCache, true, this);
 }
 public void AddOnPostMapRequestHandlerAsync(BeginEventHandler beginHandler, EndEventHandler endHandler, object state)
 {
     AsyncEvents.AddHandler(EventPostMapRequestHandler, beginHandler, endHandler, state, RequestNotification.MapRequestHandler, true, this);
 }
		public void AddOnUpdateRequestCacheAsync (BeginEventHandler beg, EndEventHandler end, object state)
		{
			if (null == _updateRequestCacheAsync)
				_updateRequestCacheAsync = new AsyncEvents ();

			_updateRequestCacheAsync.Add (beg, end, state);
		}
		public void AddOnBeginRequestAsync (BeginEventHandler beg, EndEventHandler end)
		{
			if (null == _beginRequestAsync)
				_beginRequestAsync = new AsyncEvents ();

			_beginRequestAsync.Add (beg, end);
		}
		public void AddOnPostRequestHandlerExecuteAsync (BeginEventHandler beg, EndEventHandler end)
		{
			if (null == _postRequestHandlerExecuteAsync)
				_postRequestHandlerExecuteAsync = new AsyncEvents ();

			_postRequestHandlerExecuteAsync.Add (beg, end);
		}
		public void AddOnAcquireRequestStateAsync (BeginEventHandler beg, EndEventHandler end)
		{
			if (null == _acquireRequestStateAsync)
				_acquireRequestStateAsync = new AsyncEvents ();

			_acquireRequestStateAsync.Add (beg, end);
		}
示例#25
0
 public EventMessage(ProgressChangedEventArgs evt, AsyncEvents eventType)
 {
     m_ProgressPercentage = evt.ProgressPercentage;
     m_ExchangeRequest    = (ExchangeRequest)evt.UserState;
     m_EventType          = eventType;
 }