Beispiel #1
0
 public void HelloWorld(ContextRouter router, ContextItem item, [Context(nameof(GetPage))] HttpContext httpContext)
 {
     httpContext.Response.Write(String.Format("<p>{0} Hello World!</p>", DateTime.Now.ToString("ss.fff")));
     router.Publish <Wait1>(item.AsyncContext);
     router.Publish <GetPeople>(item.AsyncContext);
     router.Publish <GetPets>(item.AsyncContext);
 }
Beispiel #2
0
        public void OnGetPeople(ContextRouter router, ContextItem item)
        {
            // Simulate having queried people:
            var people = new People();

            // Simulate the query having taken some time.
            Thread.Sleep(250);
            router.Publish <People>(people, item.AsyncContext);
        }
Beispiel #3
0
    public IAsyncResult BeginProcessRequest(HttpContext httpContext, AsyncCallback callback, Object extraData)
    {
        TaskCompletionSource <bool> tcs = new TaskCompletionSource <bool>();
        Task t = tcs.Task;

        t.ContinueWith(_ =>
        {
            httpContext.Response.Write(String.Format("<p>{0} Publishing HttpContext...</p>", DateTime.Now.ToString("ss.fff")));
            AsyncContext asyncContext = new AsyncContext();
            contextRouter.Publish(httpContext, asyncContext);
            contextRouter.WaitForCompletion(asyncContext);
            contextRouter.Cleanup(asyncContext);
            callback(t);
        });

        tcs.SetResult(true);

        return(t);
    }
Beispiel #4
0
        public CPDesigner()
        {
            InitializeComponent();

            AppDomain.CurrentDomain.ReflectionOnlyAssemblyResolve += ReflectionOnlyAssemblyResolve;
            ContextRouter myContextRouter = InitializeMyContextRouter();

#if MyContext
            ContextRouter otherContextRouter = myContextRouter;
#else
            ContextRouter otherContextRouter = Listeners.Listeners.InitializeContext();
#endif
            myContextRouter.OnException += (_, cei) => MessageBox.Show(cei.Exception.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);

            WireUpEvents(myContextRouter);
            myContextRouter.Run();

            Shown           += (_, __) => myContextRouter.Publish <Startup>(otherContextRouter);
            canvasController = InitializeFlowSharp();
        }
Beispiel #5
0
        protected void Execute(ContextRouter router, ContextItem item, ContextRouter otherContextRouter)
        {
            // Publish after the form is shown, otherwise the InvokeRequired will return false even though
            // we're handling the publish on a separate thread.
            router.Publish <ListenerTextBox>(tbListener, isStatic: true);
            router.Publish <LogTextBox>(tbLog, isStatic: true);
            router.Publish <ListenerListBox>(lbListeners, isStatic: true);
            router.Publish <ContextListBox>(lbContexts, isStatic: true);
            router.Publish <ParametersListBox>(lbParameters, isStatic: true);
            router.Publish <PublishesListBox>(lbPublishes, isStatic: true);
            router.Publish <ActiveListenersListBox>(lbActiveListeners, isStatic: true);
            router.Publish <ContextTypeMapsListBox>(lbContextTypeMaps, isStatic: true);
            router.Publish <OtherContextRouter>(otherContextRouter, isStatic: true);
            router.Publish <CanvasController>(canvasController, isStatic: true);
#if MyContext
            router.Publish <StartingListener>(nameof(CPDesigner));
#else
            router.Publish <StartingListener>("HelloWorld");
#endif
        }
Beispiel #6
0
        // Using tuples gets ugly because we don't have any context of which listbox is which.
        // Consider using a class as a container, or a container for each listbox so we have strongly-typed parameters.

        protected void WireUpEvents(ContextRouter myContextRouter)
        {
            lbListeners.SelectedIndexChanged += (_, __) => myContextRouter.Publish <SelectedListener>(lbListeners.SelectedItem.ToString());
            lbContexts.SelectedIndexChanged  += (_, __) => myContextRouter.Publish <SelectedContext>(lbContexts.SelectedItem.ToString());
        }
Beispiel #7
0
 public void OnWait1(ContextRouter router, ContextItem item, [Context(nameof(GetPage))] HttpContext httpContext)
 {
     Thread.Sleep(500);
     httpContext.Response.Write(String.Format("<p>{0} Wait 1</p>", DateTime.Now.ToString("ss.fff")));
     router.Publish <Wait2>(item.AsyncContext);
 }