Search Results for

    Show / Hide Table of Contents

    Runtime Connection Migration

    Connecting to the Runtime

    The new adapter uses a fluent builder style of runtime creation, similiar to how frameworks such as ASP.NET Core now work.

    • Original
    • New
    Runtime runtime = Runtime.GetRuntimeInstance(new RuntimeOptions
    {
        Version = "stable",
        UUID = "the-app-uuid",
        LicenseKey = "your-license-key"
    });
    
    runtime.Error += (sender, e) => {
        // Handle any connection errors...
    };
    
    runtime.Connect(() =>
    {
        // Now connected
    
        // Note: The callback is invoked on another thread so any UI access must be marshalled to the main thread
        App.Current.Dispatcher.BeginInvoke(() =>
        {
            status.Content = "Connected";
        });
    
        // Do stuff with the runtime...
    });
    
    IRuntime runtime = new RuntimeFactory()
                    .GetRuntimeInstance(new RuntimeOptions
                    {
                        Version = "stable",
                        UUID = "the-app-uuid",
                        LicenseKey = "your-license-key"
                    });
    
    try
    {
        await runtime.ConnectAsync();
    
        logger.Information("Runtime Connected");
    
        // We are back on the original thread, no need to marshal
        status.Content = "Connected";
    
        // Do stuff with the runtime...
    }
    catch ( Exception ex )
    {
        // Handle any connection errors...
    }                
    
    In This Article
    Back to top Copyright OpenFin