示例#1
0
        /// <summary>
        /// Create and start a new thread. This function does not block waiting for the
        /// thread to run initialization. |displayName| is the name that will be used to
        /// identify the thread. |priority| is the thread execution priority.
        /// |messageLoopType| indicates the set of asynchronous events that the thread
        /// can process. If |stoppable| is true (1) the thread will stopped and joined on
        /// destruction or when stop() is called; otherwise, the the thread cannot be
        /// stopped and will be leaked on shutdown. On Windows the |comInitMode| value
        /// specifies how COM will be initialized for the thread. If |comInitMode| is
        /// set to COM_INIT_MODE_STA then |messageLoopType| must be set to ML_TYPE_UI.
        /// </summary>
        /// <remarks>
        /// See also the original CEF documentation in
        /// <see href="https://bitbucket.org/chromiumfx/chromiumfx/src/tip/cef/include/capi/cef_thread_capi.h">cef/include/capi/cef_thread_capi.h</see>.
        /// </remarks>
        public static CfrThread Create(string displayName, CfxThreadPriority priority, CfxMessageLoopType messageLoopType, bool stoppable, CfxComInitMode comInitMode)
        {
            var call = new CfxThreadCreateRemoteCall();

            call.displayName     = displayName;
            call.priority        = (int)priority;
            call.messageLoopType = (int)messageLoopType;
            call.stoppable       = stoppable;
            call.comInitMode     = (int)comInitMode;
            call.RequestExecution();
            return(CfrThread.Wrap(new RemotePtr(call.__retval)));
        }
示例#2
0
        internal static CfrThread Wrap(RemotePtr remotePtr)
        {
            if (remotePtr == RemotePtr.Zero)
            {
                return(null);
            }
            var weakCache = CfxRemoteCallContext.CurrentContext.connection.weakCache;

            lock (weakCache) {
                var cfrObj = (CfrThread)weakCache.Get(remotePtr.ptr);
                if (cfrObj == null)
                {
                    cfrObj = new CfrThread(remotePtr);
                    weakCache.Add(remotePtr.ptr, cfrObj);
                }
                return(cfrObj);
            }
        }