I answer my own question, finally I discover how to do it, i just need to wrap the method around the [HandleProcessCorruptedStateExceptions] from System.Runtime.ExceptionServices and use a Try Catch in the correct part of the method, like this
[HandleProcessCorruptedStateExceptions]
void myFunction()
{
try
{
switch (sequence)
{
case 0:
sequence++;
m_FPMAux.MatchIsoTemplate(customer.Huella, i, m_VrfMin, 0, m_SecurityLevel, ref matched);
break;
case 1:
sequence++;
m_FPMAux.MatchIsoTemplate(m_VrfMin, 0, customer.Huella, i, m_SecurityLevel, ref matched); .......