IEngine Interface |
Namespace: DotNetBrowser.Engine
public interface IEngine : IDisposable, IAutoDisposable<EngineDisposedEventArgs>, IAutoDisposable
The IEngine type exposes the following members.
Name | Description | |
---|---|---|
CookieStore | Obsolete.
Gets the cookie service that allows managing cookies for the default profile.
| |
Downloads | Obsolete.
Gets the service that allows managing downloads for the default profile.
| |
HttpCache | Obsolete.
Gets the HTTP cache service for the default profile.
| |
IsDisposed |
Indicates if the object is already disposed.
(Inherited from IAutoDisposable.) | |
MediaDevices |
Gets the service that allows managing media stream devices.
| |
Network | Obsolete.
Gets the service that allows working with network for the default profile.
| |
Options |
Gets the options that were used to initialize this IEngine.
| |
Permissions | Obsolete.
Gets the service that allows managing permissions for the default profile.
| |
Plugins | Obsolete.
Gets the service that allows configuring plugins for the default profile.
| |
Profiles |
Gets the live collection of the Chromium profiles available in this engine.
| |
Proxy | Obsolete.
Gets the service that allows working with proxy for the default profile.
| |
SpellChecker | Obsolete.
Gets the service that allows working with spell checking functionality for the default profile.
| |
ZoomLevels | Obsolete.
Gets the service that allows working with zoom for the default profile.
|
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 engine = EngineFactory.Create(engineOptions);