Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 23 additions & 6 deletions Smartcard_API/GemCard/CardBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ abstract public class CardBase : ICard, IDisposable
protected const uint WAIT_TIME = 250;

protected bool m_bRunCardDetection = true;
protected Thread m_thread = null;
protected Dictionary<string, Thread> m_threads = new Dictionary<string, Thread>();

/// <summary>
/// Event handler for the card insertion
Expand Down Expand Up @@ -114,28 +114,45 @@ public virtual ControlResponse Control(IntPtr cardHandle, ControlCommand control
/// <summary>
/// This method should start a thread that checks for card insertion or removal
/// </summary>
/// <param name="Reader"></param>
/// <param name="r"></param>
/// <returns>true if the events have been started, false if they are already running</returns>
public bool StartCardEvents(string Reader)
public bool StartCardEvents(string reader)
{
bool ret = false;

Thread m_thread;
m_threads.TryGetValue(reader, out m_thread);

if (m_thread == null)
{
m_bRunCardDetection = true;

m_thread = new Thread(() => RunCardDetection(Reader));
m_thread.Start(Reader);
m_thread = new Thread(() => RunCardDetection(reader));
m_thread.Start();

m_threads[reader] = m_thread;

ret = true;
}

return ret;
}

public void StopCardEvents()
{
foreach (string reader in m_threads.Keys)
{
StopCardEvents(reader);
}
}

/// <summary>
/// Stops the card events thread
/// </summary>
public void StopCardEvents()
public void StopCardEvents(string reader)
{
Thread m_thread = m_threads[reader];

if (m_thread != null)
{
int
Expand Down