What are you trying to do here exactly?
Look at your code!!!
IPlugin plug =
while (true)
{
int code = plug.DoPluginCode();
if (code < 0)
{
plug.NotifyError(code);
}
}
there is a while loop which will run continuously. When the loop executes, each time it will spawn an new thread and it throws exception, the system will be filled with such threads! May be this is the reason why your application crashes.
Try doing this
IPlugin plug =
int code = plug.DoPluginCode();
if (code < 0)
{
plug.NotifyError(code);
}
Try not to throw exception and try.
Or tell me exactly what you want your plugin to do.