Method CreateAsync
- Namespace
- DotNetBrowser.Engine
- Assembly
- DotNetBrowser.Core.dll
CreateAsync()
Asynchronously creates and returns an IEngine instance.
public static Task<IEngine> CreateAsync()
Returns
- Task<IEngine>
A task which returns an initialized Chromium engine on completion. The task can throw EngineInitializationException if the IEngine initialization has failed for some reason.
Remarks
Calling this method is equivalent to calling the CreateAsync(EngineOptions)
method with the EngineOptions built by calling new EngineOptions.Builder().Build().
CreateAsync(EngineOptions)
Asynchronously creates and returns an IEngine instance.
public static Task<IEngine> CreateAsync(EngineOptions options)
Parameters
optionsEngineOptionsThe EngineOptions instance that will be used for initializing the engine
Returns
- Task<IEngine>
A task which returns an initialized Chromium engine on completion. The task can throw EngineInitializationException if the IEngine initialization has failed for some reason.
Examples
string dataDir = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString());
Directory.CreateDirectory(dataDir);
EngineOptions engineOptions = new EngineOptions.Builder
{
UserDataDirectory = dataDir
}
.Build();
IEngine engine = await EngineFactory.CreateAsync(engineOptions);
Exceptions
- NotSupportedException
Native keyboard input is enabled with hardware-accelerated rendering on Windows or Linux.
CreateAsync(RenderingMode)
Asynchronously creates and returns an IEngine instance.
public static Task<IEngine> CreateAsync(RenderingMode renderingMode)
Parameters
renderingModeRenderingModeThe RenderingMode that will be used for initializing the engine
Returns
- Task<IEngine>
A task, which returns an initialized Chromium engine on completion. The task can throw EngineInitializationException if the IEngine initialization has failed for some reason.
Remarks
Calling this method is equivalent to calling the CreateAsync(EngineOptions)
method with the EngineOptions built by calling
new EngineOptions.Builder().Build() with the rendering mode specified.