1
I’m having a problem with my application. The same continues in the list of processes even after its completion, besides it, also appears in the list the application Clickonce.
Setting
My application communicates with a turnstile through a dll
, and this communication is managed by a thread
in the state while(true)
.
It turns out that eventually the thread
is terminated without explanation/Exception. I then have another thread
whether the thread
original .isAlive
, if it is false
the same as a new call in thread
. But at this time an error occurs, stating that you cannot access dll
why it is being used by another thread
.
Follow an example of the code:
public static Thread th;
public static Thread thVerify;
void btnIniciar_Click(...)
{
th = new Thread(() => IniciarCatraca());
thVerify = new Thread(() => IniciarVerificacaoThread(th));
th.Start();
thVerify.Start();
}
public void IniciarVerificacaoThread(Thread t)
{
try
{
while(true)
if (t == null || !t.isAlive())
th = new Thread(() => IniciarCatraca());
}
catch(Exception ex)
{
CallCatch(ex);
}
}
It checks correctly if the thread
th is active, but still gives exception
when trying to start the turnstile again, informing that the dll
is already in use by another thread
, whereas the thread
was closed!
Then, I finish the application and open the process manager. There are two processes ClickOnce
and ProjetoCatraca
. If I open the application again and try to start the communication with the ratchet without before finalizing the processes is returned me the same error, the dll
is being used by another thread
.
Could you tell me why the application remains on the list of cases even after its closure?
This can be caused by the use of thread
?
Is there any way to verify the existence of a thread
using methods other than those expressed in my code? Any suggestions?
In which part of the code the thread is terminated?
– perozzo
o Hometurnstile(); When the turnstile takes too long to respond or when there is a failure to communicate with it in any of the calls made by th to the turnstile, such as releasing turn, checking card and etc.. Communication with the ratchet is via the network. .
– ISFO