private Task <List <String> > GetIdentificationsAsync()
    {
        var tcs = new TaskCompletionSource <List <string> >();

        try {
            var control = new R100DeviceControl();
            Action <List <string> > handler = null;
            handler = result => {
                // Once event raised then set the
                // Result property on the underlying Task.
                control.OnUserDB -= handler;    //optional to unsubscribe from event
                tcs.TrySetResult(result);
            };
            control.OnUserDB += handler;
            control.Open();
            int count = 0;
            //call async event
            int nResult = control.DownloadUserDB(out count);
        } catch (Exception ex) {
            //Bubble the error up to be handled by calling client
            tcs.TrySetException(ex);
        }
        // Return the underlying Task. The client code
        // waits on the Result property, and handles exceptions
        // in the try-catch block there.
        return(tcs.Task);
    }
Esempio n. 2
0
        } // 查看目前用戶有無虹膜眼球

        public void inicontrol()
        {
            control.OnGetIrisImage += new _IR100DeviceControlEvents_OnGetIrisImageEventHandler(OnGetIrisImage);
            control.OnEnrollReport += new _IR100DeviceControlEvents_OnEnrollReportEventHandler(OnEnrollReport);
            control.OnMatchReport  += new _IR100DeviceControlEvents_OnMatchReportEventHandler(OnMatchReport);
            //if (!Directory.Exists(_TempImagesDirectory))  // 如果沒有Temp創建一個
            //{
            //    Directory.CreateDirectory(_TempImagesDirectory);
            //}

            try
            {
                nResult = control.Close();
                nResult = control.Open();
                if (nResult != 0)
                {
                    TbMessage.AppendText("虹膜開啟失敗\r\n");
                }
                nResult = control.GetSerialNumber(out strValue);
                if (nResult != Constants.IS_ERROR_NONE)
                {
                    TbMessage.AppendText("虹膜開啟發生錯誤\r\n");
                }
                nResult = m_HostDBControl.Open(strValue);
                //LoadEnrolledUserInfo(); // 開啟時載入用戶資訊使用
            }
            catch (Exception err)
            {
                ATS.LCSCommon.WriteRunLog(err.Message);
            }
        } // 開啟時設定虹膜Control
    public void Open()
    {
        var control = new R100DeviceControl();

        control.OnUserDB += Control_OnUserDB;
        control.Open();
        // you may need to store nResult and count in a field?
        nResult = control.DownloadUserDB(out int count);
    }