mirror of
https://github.com/livebook-dev/livebook.git
synced 2025-10-11 14:06:20 +08:00
Update .NET demo projects
This commit is contained in:
parent
511df69495
commit
4681fb2bc6
2 changed files with 13 additions and 20 deletions
|
@ -1,11 +1,9 @@
|
||||||
using ElixirKit;
|
class Demo
|
||||||
|
{
|
||||||
class Demo {
|
|
||||||
public static void Main()
|
public static void Main()
|
||||||
{
|
{
|
||||||
var api = new ElixirKit.API();
|
ElixirKit.API.Start(name: "demo");
|
||||||
api.Start(name: "demo");
|
ElixirKit.API.Publish("log", "Hello from C#!");
|
||||||
api.Publish("log", "Hello from C#!");
|
ElixirKit.API.WaitForExit();
|
||||||
api.WaitForExit();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,39 +5,34 @@ static class DemoMain
|
||||||
[STAThread]
|
[STAThread]
|
||||||
static void Main()
|
static void Main()
|
||||||
{
|
{
|
||||||
var api = new ElixirKit.API(id: "com.example.Demo");
|
if (ElixirKit.API.IsMainInstance("com.example.Demo"))
|
||||||
|
|
||||||
if (api.MainInstance)
|
|
||||||
{
|
{
|
||||||
api.Start(name: "demo", exited: (exitCode) =>
|
ElixirKit.API.Start(name: "demo", exited: (exitCode) =>
|
||||||
{
|
{
|
||||||
Application.Exit();
|
Application.Exit();
|
||||||
});
|
});
|
||||||
|
|
||||||
Application.ApplicationExit += (sender, args) =>
|
Application.ApplicationExit += (sender, args) =>
|
||||||
{
|
{
|
||||||
api.Stop();
|
ElixirKit.API.Stop();
|
||||||
};
|
};
|
||||||
|
|
||||||
api.Publish("log", "Hello from Windows Forms!");
|
ElixirKit.API.Publish("log", "Hello from Windows Forms!");
|
||||||
|
|
||||||
ApplicationConfiguration.Initialize();
|
ApplicationConfiguration.Initialize();
|
||||||
Application.Run(new DemoForm(api));
|
Application.Run(new DemoForm());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
api.Publish("log", "Hello from another instance!");
|
ElixirKit.API.Publish("log", "Hello from another instance!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class DemoForm : Form
|
class DemoForm : Form
|
||||||
{
|
{
|
||||||
ElixirKit.API api;
|
public DemoForm()
|
||||||
|
|
||||||
public DemoForm(ElixirKit.API api)
|
|
||||||
{
|
{
|
||||||
this.api = api;
|
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -47,7 +42,7 @@ class DemoForm : Form
|
||||||
|
|
||||||
private void button_Click(object? sender, EventArgs e)
|
private void button_Click(object? sender, EventArgs e)
|
||||||
{
|
{
|
||||||
api.Publish("log", "button pressed!");
|
ElixirKit.API.Publish("log", "button pressed!");
|
||||||
}
|
}
|
||||||
|
|
||||||
// WinForms boilerplate below.
|
// WinForms boilerplate below.
|
||||||
|
|
Loading…
Add table
Reference in a new issue