コード例 #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 CfxThread Create(string displayName, CfxThreadPriority priority, CfxMessageLoopType messageLoopType, bool stoppable, CfxComInitMode comInitMode)
        {
            var displayName_pinned = new PinnedString(displayName);
            var __retval           = CfxApi.Thread.cfx_thread_create(displayName_pinned.Obj.PinnedPtr, displayName_pinned.Length, (int)priority, (int)messageLoopType, stoppable ? 1 : 0, (int)comInitMode);

            displayName_pinned.Obj.Free();
            return(CfxThread.Wrap(__retval));
        }
コード例 #2
0
 internal static CfxThread Wrap(IntPtr nativePtr)
 {
     if (nativePtr == IntPtr.Zero)
     {
         return(null);
     }
     lock (weakCache) {
         var wrapper = (CfxThread)weakCache.Get(nativePtr);
         if (wrapper == null)
         {
             wrapper = new CfxThread(nativePtr);
             weakCache.Add(wrapper);
         }
         else
         {
             CfxApi.cfx_release(nativePtr);
         }
         return(wrapper);
     }
 }