I've been working on this for a week now and used StackOverflow extensively, but I can't figure this out.
I'm writing a plug-in in C# in an Autodesk product, and I'm connected (with Marshal) to a different 3D application. I've done this for dozens of other plug-ins in the past without issue.
This project is unique. From the different 3D application, I'm running a long-running task (file export) on a large model. It takes 1-60 minutes at times.
I get the poison message: "This action cannot be completed because the 'application' is not responding. Choose "Switch To" and..." Technically, I can let the client just click "Retry" until it finds the application, but that is undesirable.
I originally thought I would just put a DoEvents type thing, and it would wait for the export to finish, but the poison message appears while the export sub is running (this is my first occurrence with poison messages, so I'm learning). Then I looked into running this export operation on a background thread, testing ThreadPool and Thread operations. However, I can "start" the service, but it never exports the model from the different 3D application. It just runs forever. (I removed the error message from my original post because I'm not looking for a solution to that sub-problem, but rather what I'm about to describe below)
Lastly, I tried to modify the NetMsmqBinding (I know nothing about this either, but trying to learn it) in the hopes that it will set the number of allowed retries to a bigger number.
System.TimeSpan TS = new System.TimeSpan(0, 30, 10);
System.TimeSpan TB = new System.TimeSpan(10, 0, 0);
NetMsmqBinding NMB = new NetMsmqBinding();
NMB.MaxRetryCycles = 1000;
NMB.ReceiveRetryCount = 1000;
NMB.RetryCycleDelay = TS;
NMB.OpenTimeout = TB;
However, no matter what I change my NetMsmqBinding values to, I always get the "retry" message at the same time. I must not be writing it correctly. In other examples, I noticed an xml file containing these values, and I don't know what that xml is. Nor do I really want to know, because I'd rather have this run in the plug-in, rather than have another xml file to deal with.
I'm finding lots of examples on how to deal with this in the hypothetical (lots of console.write BS), but nothing that actually has a concrete example where a long running COM process is interrupting the main C# utility.
I'd really like to figure out how to reset the retry frequency and cycles to last longer, so that the poison messages aren't presented. How can I do that?
Here is more code, to give some context:
namespace Testing_V0
{
[PluginAttribute("Testing_V0R1", "ADSK", ToolTip = "Testing the plugin", DisplayName = "Testing the plugin")]
[AddInPluginAttribute(AddInLocation.AddIn)]
public class MyPlugin : AddInPlugin
{
public override int Execute(params string[] parameters)
{
System.TimeSpan TS = new System.TimeSpan(0, 30, 10);
System.TimeSpan TB = new System.TimeSpan(10, 0, 0);
NetMsmqBinding NMB = new NetMsmqBinding();
NMB.MaxRetryCycles = 1000;
NMB.ReceiveRetryCount = 1000;
NMB.RetryCycleDelay = TS;
NMB.OpenTimeout = TB;
//NMB.ReceiveErrorHandling = ReceiveErrorHandling.Drop;
//Do the Export process here
}
}
}