Exemple #1
0
        public override IAsyncResult BeginCreatePortMap(Mapping mapping, AsyncCallback callback, object asyncState)
        {
            PortMapAsyncResult pmar = new PortMapAsyncResult(mapping.Protocol, mapping.PublicPort, PmpConstants.DefaultLeaseTime, callback, asyncState);

            ThreadPool.QueueUserWorkItem(delegate
            {
                try
                {
                    CreatePortMap(pmar.Mapping, true);
                    pmar.Complete();
                }
                catch (Exception e)
                {
                    pmar.Complete(e);
                }
            });
            return(pmar);
        }
Exemple #2
0
        public override IAsyncResult BeginDeletePortMap(Mapping mapping, AsyncCallback callback, object asyncState)
        {
            PortMapAsyncResult pmar = new PortMapAsyncResult(mapping, callback, asyncState);

            ThreadPool.QueueUserWorkItem(delegate
            {
                try
                {
                    CreatePortMap(pmar.Mapping, false);
                    pmar.Complete();
                }
                catch (Exception e)
                {
                    pmar.Complete(e);
                }
            });
            return(pmar);
        }
Exemple #3
0
        public override void EndDeletePortMap(IAsyncResult result)
        {
            PortMapAsyncResult pmar = result as PortMapAsyncResult;

            pmar.AsyncWaitHandle.WaitOne();
        }