Click or drag to resize

IEngine Interface

Provides access to the Chromium engine functionality.

Namespace:  DotNetBrowser.Engine
Assembly:  DotNetBrowser (in DotNetBrowser.dll) Version: 2.1.1
Syntax
C#
public interface IEngine : IDisposable, 
	IAutoDisposable<EngineDisposedEventArgs>, IAutoDisposable

The IEngine type exposes the following members.

Properties
  NameDescription
Public propertyCookieStore
Gets the cookie service that allows managing cookies.
Public propertyDownloads
Gets the service that allows managing downloads.
Public propertyHttpCache
Gets the HTTP cache service.
Public propertyIsDisposed
Indicates if the object is already disposed.
(Inherited from IAutoDisposable.)
Public propertyMediaDevices
Gets the service that allows managing media stream devices.
Public propertyNetwork
Gets the service that allows working with network.
Public propertyOptions
Gets the options that were used to initialize this IEngine.
Public propertyPermissions
Gets the service that allows managing permissions.
Public propertyPlugins
Gets the service that allows configuring plugins.
Public propertyProxy
Gets the service that allows working with proxy.
Public propertySpellChecker
Gets the service that allows working with spell checking functionality.
Public propertyZoomLevels
Gets the service that allows working with zoom.
Top
Methods
  NameDescription
Public methodCreateBrowser
Creates a new IBrowser instance with the initial "about:blank" web page.
Public methodDispose
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
(Inherited from IDisposable.)
Top
Events
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.
});
Examples
Create IEngine
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);
See Also