コード例 #1
0
        public void Configuration(IAppBuilder app)
        {
            app.Run(context =>
            {
                Stopwatch stopWatch = new Stopwatch();
                Trace.WriteLine("Received client call. Starting stop watch now.");
                stopWatch.Start();

                context.Request.CallCancelled.Register(() =>
                {
                    stopWatch.Stop();
                    Trace.WriteLine(string.Format("Cancellation token triggered. Elapsed time : {0}. Test should succeed", stopWatch.Elapsed));
                    NotificationServer.NotifyClient();
                });

                int retryCount = 0;
                while (retryCount < 3)
                {
                    Thread.CurrentThread.Join(5 * 1000);
                    if (context.Request.CallCancelled.IsCancellationRequested)
                    {
                        break;
                    }
                    retryCount++;
                }

                return(context.Response.WriteAsync("FAILURE"));
            });
        }
コード例 #2
0
        public bool WriteCore(TraceEventType eventType, int eventId, object state, Exception exception, Func <object, Exception, string> formatter)
        {
            if (expectedMessages.Contains(state.ToString()) &&
                state.ToString().Contains(eventType.ToString()))
            {
                expectedMessages.Remove(state.ToString());
            }

            if (expectedMessages.Count == 0)
            {
                NotificationServer.NotifyClient();
            }

            return(true);
        }
コード例 #3
0
        internal void Configuration(IAppBuilder app)
        {
            appDisposingTokenOnHostProperties = app.Properties.Get <CancellationToken>("host.OnAppDisposing");
            appDisposingTokenOnHostProperties.Register(() =>
            {
                NotificationServer.NotifyClient();
            });

            app.Run(context =>
            {
                var perRequestHostDisposingToken = context.Get <CancellationToken>("host.OnAppDisposing");
                if (perRequestHostDisposingToken.GetHashCode() != this.appDisposingTokenOnHostProperties.GetHashCode())
                {
                    return(context.Response.WriteAsync("FAILURE"));
                }

                return(context.Response.WriteAsync("SUCCESS"));
            });
        }