Beispiel #1
0
        public static void Invoke(this SynchronizationContext syncCtx, Action func)
        {
            var invokeCtx = new InvokeCtx()
            {
                Function = func,
                Error    = null
            };

            syncCtx.Send(InvokeFunc, invokeCtx);
            if (invokeCtx.Error != null)
            {
                throw invokeCtx.Error;
            }
        }
Beispiel #2
0
        public static TOut Invoke <TOut>(this SynchronizationContext syncCtx, Func <TOut> func)
        {
            var invokeCtx = new InvokeCtx <TOut>()
            {
                Function = func,
                Result   = default(TOut),
                Error    = null
            };

            syncCtx.Send(InvokeFunc <TOut>, invokeCtx);
            if (invokeCtx.Error != null)
            {
                throw invokeCtx.Error;
            }
            return(invokeCtx.Result);
        }