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!
Asked
Active
Viewed 99 times
0
-
There should be no problem using single-threaded code from 2 different processes... But your question is probably about something else but unclear what it is. Side note: is you "encoder" piece of software or hardware? – Alexei Levenkov Jul 09 '13 at 18:47
-
You want to change code you don't have access to the source? I am very confused – konkked Jul 09 '13 at 18:57
1 Answers
1
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.

lightbricko
- 2,649
- 15
- 21
-
Thank you for the reply's. The industrial software is running continuously and is "not triggered by my code", it is triggered directly by the encoder. The trigger events are set in my software. Passing the data through my software to the industrial software is too slow for encoder events. I am wondering if I need a third application to manage when trigger events occur to pass the data to the correct application? or is there an easier or faster way. – jester Jul 10 '13 at 17:17
-
I see, then my answer won't help you. I'm sorry, but I don't know enough about the industrial software, the encoder and the current architecture to come up with another answer. – lightbricko Jul 10 '13 at 19:25