Use Separate Thread For .NET R←2520⌶Y
This function determines the way that .NET calls are executed in APL thread 0.
The right argument Y
is a Boolean value:
- 1 : run .NET calls in a separate system thread
- 0 : run .NET calls in the same system thread
The result R
is a Boolean value which indicates the previous behaviour.
When an APL thread first makes a .NET call, it creates a unique system thread in which that and subsequent .NET calls are made. If a .NET call results in the creation of a message queue, that queue is associated with that same system thread. So each message queue is also unique. This strategy successfully maintains separation between multiple Windows message queues being executed in different APL threads.
By default, the base APL thread (thread 0) runs .NET code in the same system thread as itself. This is a different system thread to that used to run .NET code from other APL threads, so the separation between message queues associated with APL thread 0 and those associated with other APL threads is maintained. However, in certain circumstances, messages generated by .NET objects interfere with APL's internal message processing (and vice-versa), for example when handling exceptions.
For this reason, Dyalog recommends that APL code that creates instances of .NET objects that generate events (such as Windows Presentation Foundation objects) are run in a separate APL thread.
Where this is not possible, 2520⌶1
may be used to force Dyalog to use a unique system thread for .NET that is associated with APL thread 0. If so, it is recommended that 2520⌶1
is called at application start-up time.