Skip to content
This repository was archived by the owner on Oct 21, 2021. It is now read-only.
This repository was archived by the owner on Oct 21, 2021. It is now read-only.

Console Example exits premature if started by TouchPortal #8

@oddbear

Description

@oddbear

This bug is happens when the plugin is started from TouchPortal with plugin_start_cmd. Not when starting from Visual Studio and connecting to TouchPortal etc.

When a Console application is started by TouchPortal, the Console.ReadLine() does not hold the application.
Therefor this plugin will just skip the ReadLine part, and close the pluigin.

It can be changed to something like:

//Console.ReadLine();
var manualResetEvent = new ManualResetEvent(false);
manualResetEvent.WaitOne();

This will work, but then there is another issue. When TouchPortal closes, the plugin is still running.
Therefor there are two options, either use Environment.Exit(0); in the OnCloseEventHandler.

This is similar to what the Java SDK does:

    @Override
    public void onDisconnect(Exception exception) {
        // Socket connection is lost or plugin has received close message
        if (exception != null) {
            exception.printStackTrace();
        }
        System.exit(0);
    }

Or, pick in the OnCloseEventHandler and do a manualResetEvent.Set().

Using a TaskCompleationSource or similar instead of a ManualResetEvent should also work.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions