况洋洋
2025-07-04 0d247bd2a17e0f99f3609774a1ce54ae00857997
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
// Copyright © 2020 The CefSharp Authors. All rights reserved.
//
// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
 
using System;
using System.Threading;
 
namespace CefSharp.Internals
{
    /// <summary>
    /// Browser Ref counter
    /// Used internally to keep track of open browser instances
    /// The ref count is incremented when a browser is created,
    /// and decremented when the browser has successfully closed.
    /// </summary>
    public interface IBrowserRefCounter : IDisposable
    {
        /// <summary>
        /// Increment browser count
        /// </summary>
        /// <param name="type">Browser type, used for logging internally</param>
        void Increment(Type type);
 
        /// <summary>
        /// Decrement browser count
        /// </summary>
        /// <param name="type">Browser type, used for logging internally</param>
        /// <returns>returns true if the count is 0, otherwise false</returns>
        bool Decrement(Type type);
 
        /// <summary>
        /// Gets the number of CefBrowser instances currently open (this includes popups)
        /// </summary>
        /// <value>
        /// The count.
        /// </value>
        int Count { get; }
 
        /// <summary>
        /// Enable logging
        /// </summary>
        void EnableLogging();
 
        /// <summary>
        /// Gets the log (empty if not enabled).
        /// </summary>
        /// <returns>string</returns>
        string GetLog();
 
        /// <summary>
        /// Blocks until the CefBrowser count has reached 0 or the timeout has been reached
        /// </summary>
        /// <param name="timeoutInMiliseconds">(Optional) The timeout in miliseconds.</param>
        void WaitForBrowsersToClose(int timeoutInMiliseconds = 500);
 
        /// <summary>
        /// Blocks until the CefBrowser count has reached 0 or the timeout has been reached
        /// </summary>
        /// <param name="timeoutInMiliseconds">(Optional) The timeout in miliseconds.</param>
        /// <param name="cancellationToken">(Optional) The cancellation token.</param>
        void WaitForBrowsersToClose(int timeoutInMiliseconds, CancellationToken cancellationToken);
    }
}