TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
paulo gomes
NA
9
0
How to verify if a static class is running/active
Aug 24 2018 1:07 PM
Hi all,
The scenario is a multi-thread environment as below:
.
a static class
accessDLLlock
has several internal methods.
. A static object
_objectLocker
is declared in the constructor.
. Each method in
accessDLLLock
executes a lock to
_objectLocker
and t
hen redirects the call to a method in a DLL that is
non thread-safe
(the reason for the lock)
.The next call to
accessDLLLock
will add the request to the queue (FIFO) if the class is still locked; it will be answered only when the lock is released
QUESTION
: how to know if
accessDLLLock
is running (or locked) before calling it?
Thank you for your time,
Paulo
Below part of the
accessDLLLock
code:
------------------------------------------
namespace Myservice
{
public static class accessDllLock
{
//declares the static object to synchronize the lock with incoming calls
static
readonly
object
_objectLocker
= new object();
public static string
function_1_to_lock
(string arg_input)
{
lock (
_objectLocker
)
try
{ statements to call the method
function_1
in a DLL non thread safe }
}
public static string
function_2_to_lock (string arg_input)
{
lock (
_objectLocker
)
try
{ statements to call the method
function_2
in a DLL non thread safe }
}
...
}
Reply
Answers (
2
)
What can be my if statement?
How to Windows Forms CheckBox respond?