Let's set some baselines...
- EXE runs
- EXE loads a DLL containing plugins
- EXE instantiates a type (the "plugin")
- Plugin starts waiting for an event
- EXE waits
- External event (on another thread) is noted by the plugin instance
- EXE is notified of the event
If this is the case, the simplest thing is to define an event in your plugin type.
public interface IPlugin
{
public event EventHandler SomethingHappened;
public void StartWatchingForSomething();
}
where the code would be something like...
public static void Main()
{
foreach (var plugin in LoadAllPluginTypes()) // IoC container, MEF, something
{
plugin.SomethingHappened += SomethingHappenedEventHandler;
plugin.StartWatchingForSomething();
}
public void SomethingHappenedEventHandler(object sender, EventArgs e)
{
//derp
}
}
Please note, the event handlers are going to be firing on the same thread as the notification comes in on. For example, if your plugin is responding to file system events (via the FileSystemWatcher), the event handlers will be firing on the same thread as the thread that's executing code "defined in the dll".
If your EXE is a winforms or WPF project, you'll have to do an Invoke or Dispatcher.Invoke to get on the UI thread before updating any visual controls.