Interface IEngine
- Namespace
- DotNetBrowser.Engine
- Assembly
- DotNetBrowser.dll
Provides access to the Chromium engine functionality.
public interface IEngine : IDisposable, IAutoDisposable<EngineDisposedEventArgs>, IAutoDisposable
- Inherited Members
Remarks
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);</code></pre>
Properties
- MediaDevices
Gets the service that allows managing media stream devices.
- Profiles
Gets the live collection of the Chromium profiles available in this engine.
- Theme
Gets or sets the current Chromium theme.
Methods
- CreateBrowser()
Creates a new IBrowser instance with the initial "about:blank" web page.