IEngine Interface |
Namespace: DotNetBrowser.Engine
public interface IEngine : IDisposable, IAutoDisposable<EngineDisposedEventArgs>, IAutoDisposable
The IEngine type exposes the following members.
| Name | Description | |
|---|---|---|
| CookieStore |
Gets the cookie service that allows managing cookies.
| |
| Downloads |
Gets the service that allows managing downloads.
| |
| HttpCache |
Gets the HTTP cache service.
| |
| IsDisposed |
Indicates if the object is already disposed.
(Inherited from IAutoDisposable.) | |
| MediaDevices |
Gets the service that allows managing media stream devices.
| |
| Network |
Gets the service that allows working with network.
| |
| Options |
Gets the options that were used to initialize this IEngine.
| |
| Permissions |
Gets the service that allows managing permissions.
| |
| Plugins |
Gets the service that allows configuring plugins.
| |
| Proxy |
Gets the service that allows working with proxy.
| |
| SpellChecker |
Gets the service that allows working with spell checking functionality.
| |
| ZoomLevels |
Gets the service that allows working with zoom.
|
| Name | Description | |
|---|---|---|
| CreateBrowser |
Creates a new IBrowser instance with the initial "about:blank" web page.
| |
| Dispose | Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources. (Inherited from IDisposable.) |
| Name | Description | |
|---|---|---|
| Disposed |
Occurs when the object has been disposed.
(Inherited from IAutoDisposableTArgs.) |
To perform operations with the engine, a license key is required. The license key represents a string that can be set via the dotnetbrowser.license file or individually for every IEngine using the LicenseKey property. If you set the license key via configuring the license file, then please make sure that you set it before creating an IEngine instance.
The Chromium engine is running in a separate native process. Communication between the native and .NET process is done through the Inter-Process Communication (IPC) layer that allows transferring data between two processes on a local machine.
The native process allocates memory and system resources that must be released. So, when the engine is no longer needed, it must be disposed through the Dispose method to shutdown the native process and free all the allocated memory and system resources. For example:
IEngine engine = EngineFactory.Create(engineOptions);
//...
engine.Dispose();Any attempt to use an already disposed engine or any of its services will lead to the InvalidOperationException.
To get notifications that the IEngine instance has been disposed subscribe to the following event:
engine.Disposed += (s, e) => {
// The engine has been disposed or unexpectedly crashed.
});To get notifications that the IEngine instance has been unexpectedly crashed use:
engine.Disposed += (s, e) => {
long exitCode = e.ExitCode;
// The engine has been crashed if this exit code is non-zero.
});string dataDir = TestUtil.GenerateCustomFolderPath(); Debug.WriteLine($"Data directory: {dataDir}"); Directory.CreateDirectory(dataDir); EngineOptions engineOptions = new EngineOptions.Builder { UserDataDirectory = dataDir, } .Build(); IEngine engineService = EngineFactory.Create(engineOptions);