पर अपवाद मुझे इस अपवाद के बारे में अलग-अलग लेख मिल गए हैं, लेकिन उनमें से कोई भी मेरा मामला नहीं था। यहाँ स्रोत कोड है:ऑब्जेक्ट सिंक्रनाइज़ेशन विधि को कोड के एक सिंक्रनाइज़ किए गए ब्लॉक से बुलाया गया था। Mutex.Release()
class Program
{
private static Mutex mutex;
private static bool mutexIsLocked = false;
static void Main(string[] args)
{
ICrmService crmService =
new ArmenianSoftware.Crm.Common.CrmServiceWrapper(GetCrmService("Armsoft", "crmserver"));
//Lock mutex for concurrent access to workflow
mutex = new Mutex(true, "ArmenianSoftware.Crm.Common.FilterCtiCallLogActivity");
mutexIsLocked = true;
//Create object for updating filtered cti call log
ArmenianSoftware.Crm.Common.FilterCtiCallLog filterCtiCallLog =
new ArmenianSoftware.Crm.Common.FilterCtiCallLog(crmService);
//Bind events
filterCtiCallLog.CtiCallsRetrieved += new EventHandler<ArmenianSoftware.Crm.Common.CtiCallsRetrievedEventArgs>(filterCtiCallLog_CtiCallsRetrieved);
//Execute filter
try
{
filterCtiCallLog.CreateFilteredCtiCallLogSync();
}
catch (Exception ex)
{
throw ex;
}
finally
{
if (mutexIsLocked)
{
mutexIsLocked = false;
mutex.ReleaseMutex();
}
}
}
static void filterCtiCallLog_CtiCallsRetrieved(object sender,
ArmenianSoftware.Crm.Common.CtiCallsRetrievedEventArgs e)
{
tryasasas
{
if (mutexIsLocked)
{
mutexIsLocked = false;
mutex.ReleaseMutex();
}
}
catch (Exception ex)
{
throw ex;
}
}
}
filterCtiCallLog.CreateFilteredCtiCallLogSync();
समारोह सर्वर के लिए अनुरोध निष्पादित करता है, और कुछ घटनाओं, CtiCallsRetrieve
घटना है, जिनमें से एक को जन्म देती है। और जब इस घटना को निकाल दिया जाता है तो मुझे म्यूटेक्स को छोड़ना होगा। लेकिन mutex को कॉल करने पर। कृपया() फ़ंक्शन अपवाद फेंक दिया गया है। CreateFilteredCtiCallLogSync
तुल्यकालिक रूप से काम करता है। समस्या क्या है?
आप सही हैं - मुझे याद आया कि कॉलबैक सेट करने वाला धागा मुख्य धागा है :( –
ऑटोरेटेवेंट बहुत अच्छा है! धन्यवाद हंस। –