Пример #1
0
        public static AsyncAction StartNew(AsyncAction function)
        {
            bool   completed = false;
            object sync      = new object();

            function.BeginInvoke(delegate(IAsyncResult iAsyncResult)
            {
                lock (sync)
                {
                    completed = true;
                    function.EndInvoke(iAsyncResult);
                    Monitor.Pulse(sync);
                }
            }, null);
            return(delegate
            {
                lock (sync)
                {
                    if (!completed)
                    {
                        Monitor.Wait(sync);
                    }
                }
            });
        }
Пример #2
0
        // Token: 0x0600000B RID: 11 RVA: 0x000024E0 File Offset: 0x000006E0
        public static AsyncAction <R> StartNew <R>(AsyncAction <R> function)
        {
            R      retv      = default(R);
            bool   completed = false;
            object sync      = new object();

            function.BeginInvoke(delegate(IAsyncResult iAsyncResult)
            {
                object sync = sync;
                lock (sync)
                {
                    completed = true;
                    retv      = function.EndInvoke(iAsyncResult);
                    Monitor.Pulse(sync);
                }
            }, null);
            return(delegate()
            {
                object sync = sync;
                R retv;
                lock (sync)
                {
                    if (!completed)
                    {
                        Monitor.Wait(sync);
                    }
                    retv = retv;
                }
                return retv;
            });
        }