{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Embedded kernels \n", "\n", "This notebook and the C# project in this folder demonstrates how you can use .NET Interactive to embed a kernel within an app, connect to it from another kernel, and use the notebook to change the app's runtime state.\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "\n", "## Connect to the WPF app\n", "\n", "First, let's start the WPF app and connect to it." ] }, { "cell_type": "code", "execution_count": 1, "metadata": { "dotnet_interactive": { "language": "pwsh" } }, "outputs": [], "source": [ "Start-Process -NoNewWindow dotnet run" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Once the cell above has finished running, you should see the app's window open. Next, we'll connect to it using a named pipe. The code that sets this up within the WPF app can be seen in [`App.xaml.cs`](https://github.com/dotnet/interactive/blob/main/samples/connect-wpf/App.xaml.cs)." ] }, { "cell_type": "code", "execution_count": 3, "metadata": { "dotnet_interactive": { "language": "csharp" } }, "outputs": [ { "data": { "text/plain": [ "Kernel added: #!wpf" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "#!connect named-pipe --kernel-name wpf --pipe-name InteractiveWpf" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The topology of connected kernels now looks like this:" ] }, { "cell_type": "code", "execution_count": 3, "metadata": { "dotnet_interactive": { "language": "mermaid" } }, "outputs": [ { "data": { "text/html": [ "