Exemplo n.º 1
0
        public static void CallDelegatorByAsync(Delegate dl, Object[] parameters, bool controlInvoke, bool parallelInvocation, AsyncRaiserCallback callback, Object state)
        {
            TypeContainer    container = null;
            TypeNameResolver name_res  = new TypeNameResolver();

            lock (mTypeContainers)
            {
                if (mTypeContainers.ContainsKey(name_res.CallerTypeName))
                {
                    container = mTypeContainers[name_res.CallerTypeName];
                }
                else
                {
                    container = new TypeContainer();
                    mTypeContainers[name_res.CallerTypeName] = container;
                }

                if (container.Thread == null)
                {
                    container.Thread = new Thread(new ThreadStart(EventExecutorThreadMain));
                    container.Thread.IsBackground = true;
                    container.Thread.Name         = name_res.CallerTypeName;
                    container.Thread.Start();
                }
            }

            lock (container.Queue)
            {
                container.Queue.Enqueue(new EventDataContainer(dl, parameters, controlInvoke, parallelInvocation, callback, state));
            }

            container.ExecutorThreadSemaphore.Release();
        }
Exemplo n.º 2
0
        public static void CallDelegatorByAsync(Delegate dl, Object[] parameters, bool controlInvoke, bool parallelInvocation, AsyncRaiserCallback callback, Object state)
        {
            TypeContainer container = null;
            TypeNameResolver name_res = new TypeNameResolver();

            lock (mTypeContainers)
            {
                if (mTypeContainers.ContainsKey(name_res.CallerTypeName))
                {
                    container = mTypeContainers[name_res.CallerTypeName];
                }
                else
                {
                    container = new TypeContainer();
                    mTypeContainers[name_res.CallerTypeName] = container;
                }

                if (container.Thread == null)
                {
                    container.Thread = new Thread(new ThreadStart(EventExecutorThreadMain));
                    container.Thread.IsBackground = true;
                    container.Thread.Name = name_res.CallerTypeName;
                    container.Thread.Start();
                }
            }

            lock (container.Queue)
            {
                container.Queue.Enqueue(new EventDataContainer(dl, parameters, controlInvoke, parallelInvocation, callback, state));
            }

            container.ExecutorThreadSemaphore.Release();
        }