Click or drag to resize

IEngine Interface

Provides access to the Chromium engine functionality.

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

The IEngine type exposes the following members.

Properties
  NameDescription
Public propertyCookieStore Obsolete.
Gets the cookie service that allows managing cookies for the default profile.
Public propertyDownloads Obsolete.
Gets the service that allows managing downloads for the default profile.
Public propertyHttpCache Obsolete.
Gets the HTTP cache service for the default profile.
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 Obsolete.
Gets the service that allows working with network for the default profile.
Public propertyOptions
Gets the options that were used to initialize this IEngine.
Public propertyPermissions Obsolete.
Gets the service that allows managing permissions for the default profile.
Public propertyPlugins Obsolete.
Gets the service that allows configuring plugins for the default profile.
Public propertyProfiles
Gets the live collection of the Chromium profiles available in this engine.
Public propertyProxy Obsolete.
Gets the service that allows working with proxy for the default profile.
Public propertySpellChecker Obsolete.
Gets the service that allows working with spell checking functionality for the default profile.
Public propertyZoomLevels Obsolete.
Gets the service that allows working with zoom for the default profile.
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 engine = EngineFactory.Create(engineOptions);
See Also