Andrew Stalker
Andrew Stalker

Reputation: 757

How to use multi-threaded .NET object in OpenEdge

I am using the .NET SmtpClient class to send an email from an AppServer procedure. I have implemented some simple code to test, based on the syntax found here: https://msdn.microsoft.com/en-us/library/system.net.mail.smtpclient(v=vs.110).aspx

All of the OpenEdge syntax is correct (using the class browser, it is simple to translate the code), but the problem line is here:

mailClient:send(mailMessage).

When running the code the following error is shown:

You are trying to use a multi-threaded .NET object in a way that is not supported. The ABL cannot be called on a thread other than the main thread. (15740) The ABL is single threaded. You will see this error if you use a .NET object that employs multiple threads and attempts to call back to the ABL on a thread other than the main processing thread.

My question is how do you use a multi-threaded .NET object in ABL since it is single threaded.

Initially documentation suggested using the WAIT-FOR statement, however this did not change the result.

Upvotes: 1

Views: 672

Answers (1)

Mike Fechner
Mike Fechner

Reputation: 7182

There is no simple answer. If you do not need the response of the method, you can create a wrapper method in C#. If you need the response from the send method, you will be out of luck on the AppServer - as this would require the thread synchronization only possible with WinForm controls.

Upvotes: 1

Related Questions