Note that there are some explanatory texts on larger screens.

plurals
  1. POClose if no active threads, or if any active, then wait till it's complete and close
    text
    copied!<p>My application overview is</p> <p><a href="http://img823.imageshack.us/img823/8975/modelq.jpg" rel="nofollow noreferrer">alt text http://img823.imageshack.us/img823/8975/modelq.jpg</a></p> <p>ASP.Net webservice entertains requests from various applications for digital signing and verification via a client. The webservice will then route these requests to a smart card</p> <p>When the system date changes, I want the following to happen.</p> <ol> <li><p>New request from the clients are made to wait</p></li> <li><p>Current work between webservice and smart card should get completed</p></li> <li><p>If there is any prior pending requests then they should get completed.</p></li> </ol> <p>The reason why I need the above things to happen is, I need to close the existing sessions between the smartcard and webservice. This should happen only when there is no signing/verification of files. I cannot just close all the sessions as it might affect a file being processed by any one of the threads. So I need to make sure that there are no current active threads between webservice and smart card.</p> <p>I wrote a piece of code which gives the total number of active threads between webservice and smartcard.</p> <pre><code>int vWorkerThreads,vWorkerThreadsMax; int vPortThreads,vPortThreadsMax; System::Threading::ThreadPool ^ vThreadPool; vThreadPool-&gt;GetAvailableThreads(vWorkerThreads, vPortThreads); vThreadPool-&gt;GetMaxThreads(vWorkerThreadsMax, vPortThreadsMax); ActiveThreadCount = vWorkerThreadsMax - vWorkerThreads; </code></pre> <p>This means, I also need to make the client requests wait?</p> <p>CLEANUP MECHANISM: Close the PKCS#11 API using <code>C_CloseAllSessions</code> and <code>C_Finalize</code> call which will free up the library so that it cleans all the session objects. This should be done once everyday.</p> <p>Any ideas on how I can perform such a task?</p> <p><strong>UPDATE:</strong></p> <p>I could have been much more clearer in my query. I want to make it clear that my aim is not to shutdown the ASP.NET webservice. <strong>My aim is to reset the smartcard</strong>. As I am accessing the smartcard via ASP.NET webservice, I need a mechanism to perform this task of resetting the smart card.</p> <p>I am giving the current process below</p> <blockquote> <ol> <li>Client detects Date change, At midnight</li> <li>Client calls the function <code>WebService_Close_SmartCard</code> </li> <li>Web Service receives the request <code>WebService_Close_SmartCard</code> and in turn calls <code>PKCS11_Close_SmartCard</code>. This Call will be served via one of the available threads from the Thread Pool. <code>PKCS11_Close_SmartCard will</code> close all the existing current sessions with the smartcard.</li> <li>At this point, I want to make sure that there are no threads with function calls such as <code>PKCS11_DigitalSign_SmartCard</code>/ <code>PKCS11_DigitalVerify_SmartCard</code> talking to smartcard, as <code>PKCS11_Close_SmartCard</code> will abruptly end the other ongoing sessions.</li> </ol> </blockquote> <p>PS: I am new to ASP.NET and Multithreading.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload