コード例 #1
0
        public bool Start()
        {
            lock (_lock)
            {
                if (_state == STATE.STOPPED)
                {
                    try
                    {
                        Stopwatch stopwatch = Stopwatch.StartNew();

                        StringBuilder ip       = new StringBuilder(Config.Instance.LocalIP);
                        StringBuilder AddrName = new StringBuilder("000000000000");
                        DebugLog.TraceMessage(string.Format("done: {0}", stopwatch.Elapsed));
                        NativeMethods.Dll_SetLocalIpAddress(ip, AddrName, (uint)Config.Instance.SIPCommunicationPort);  // 花了兩秒
                        DebugLog.TraceMessage(string.Format("done: {0}", stopwatch.Elapsed));
                        _CallBack = new pCallBackPro(DllCallBackFunc);
                        NativeMethods.dll_init(_CallBack);
                        DebugLog.TraceMessage(string.Format("done: {0}", stopwatch.Elapsed));
                        NativeMethods.Dll_initCamera();
                        DebugLog.TraceMessage(string.Format("done: {0}", stopwatch.Elapsed));
                        int ndevice = NativeMethods.GetCaptureDeviceCount();
                        DebugLog.TraceMessage(string.Format("done: {0}", stopwatch.Elapsed));
                        if (ndevice > 0)
                        {
                            NativeMethods.Dll_SetCameraDeviceId(0); // 花了 1 秒
                        }
                        DebugLog.TraceMessage(string.Format("done: {0}", stopwatch.Elapsed));
                        _state = STATE.STARTED;
                    }
                    catch (Exception) { }
                }

                return(_state == STATE.STARTED);
            }
        }
コード例 #2
0
 public static extern int Dll_init([MarshalAs(UnmanagedType.FunctionPtr)] pCallBackPro func);