Exemple #1
0
        /// <summary>
        /// BeginMakeCall counterpart
        /// </summary>
        /// <param name="ar">IAsyncResult returned by <c>BeginMakeCall</c></param>
        /// <returns>New Call object, or null if failed</returns>
        public Call EndMakeCall(IAsyncResult ar)
        {
            MakeCallAsyncResult mc = ar as MakeCallAsyncResult;

            if (mc == null)
            {
                throw new ArgumentException("Invalid parameter", "ar");
            }
            if (!mc.IsCompleted)
            {
                mc.AsyncWaitHandle.WaitOne();
            }
            Call call = tapi.Calls[mc.hCall] as Call;

            if (call == null)
            {
                call = new Call(mc.m_hCall);
                tapi.Calls.Add(mc.m_hCall, call);
                call.LoadCallInfo();
                call.LoadCallState();
                //				call.OnLineCallInfo(
                //				LINECALLINFO lci = new LINECALLINFO(1024);
                //				lci.Store();
                //				int ret = NativeTapi.lineGetCallInfo(mc.m_hCall, lci.Data);
                //				if (ret >= 0)
                //				{
                //					lci.Load();
                //					call.m_line = tapi.Lines[lci.hLine] as Line;
                //				}
            }
            return(call);
        }
Exemple #2
0
        /// <summary>
        /// Asynchronous function to place a call
        /// </summary>
        /// <param name="Destination">String: phone number</param>
        /// <param name="CountryCode">int: country code, e.g. 1 for US</param>
        /// <param name="Params"><c>LINECALLPARAMS</c> structure data</param>
        /// <param name="Callback">Asynchronous callback. Will be invoked when the call is complete</param>
        /// <param name="State">User-defined state object. Can be null</param>
        /// <returns>IAsyncResult</returns>
        public IAsyncResult BeginMakeCall(string Destination, int CountryCode, /*LINECALLPARAMS*/ byte[] Params, AsyncCallback Callback, object State)
        {
            bSyncMakeCall = false;
            MakeCallAsyncResult result = new MakeCallAsyncResult(0, Callback, State);

            lock (tapi.PendingRequests.SyncRoot)
            {
                int ret = NativeTapi.lineMakeCall(m_hLine, out result.m_hCall, Destination, CountryCode, Params);
                result.ReplyID = ret;
                if (ret > 0)
                {
                    tapi.PendingRequests.Add(ret, result);
                }
            }
            return(result);
        }
Exemple #3
0
        public Call MakeCall(string Destination, int CountryCode, /*LINECALLPARAMS*/ byte[] Params)
        {
            IAsyncResult ar = BeginMakeCall(Destination, CountryCode, Params, null, null);

            bSyncMakeCall = true;
            MakeCallAsyncResult mc = ar as MakeCallAsyncResult;
            bool bDone             = false;

            while (!bDone)
            {
                Monitor.Enter(mc);
                if (mc.IsCompleted)
                {
                    bDone = true;
                }
                Monitor.Exit(mc);
                Application.DoEvents();
            }
            //			if ( !(ar as MakeCallAsyncResult).IsCompleted )
            //				ar.AsyncWaitHandle.WaitOne();
            Call call = EndMakeCall(ar);

            return(call);
        }