Question

I have written a program to enable quick configuration of an encoder as well as data acquisition to a text file. I need to be able to access the encoder through industrial software at the same time, reading the text file is not possible. I have no access to change code on the industrial software or how it even accesses the encoder (I haven't seen it). Any ideas on how to implement a layer to manage the single-threaded encoder which uses .dll libraries for access would be greatly appreciated!

Was it helpful?

Solution

If you invoke the industrial software from your code, just lock the part of your code that calls the single threaded component like this:

public class ResourceAccessorClass
{
    private object _lockObject = new object();

    public void SafeAccess()
    {
        lock (_lockObject)
        {
            // Access thread-sensitive resources.
        }
    }
}

Msdn documentation on Thread Synchronization: http://msdn.microsoft.com/en-us/library/ms173179.aspx

If the industrial software is running continuously (not triggered by your code), it's more complicated though.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top