Questo sito utilizza cookies solo per scopi di autenticazione sul sito e nient'altro. Nessuna informazione personale viene tracciata. Leggi l'informativa sui cookies.
Username: Password: oppure
C# / VB.NET - Problema RCW Cleanup
Forum - C# / VB.NET - Problema RCW Cleanup

Avatar
Sparvier0 (Normal User)
Newbie


Messaggi: 19
Iscritto: 25/02/2011

Segnala al moderatore
Postato alle 1:21
Martedė, 21/06/2011
Salve,

sono alle prese con il seguente errore:

An attempt has been made to free an RCW that is in use.  The RCW is in use on the active thread or another thread.  Attempting to free an in-use RCW can cause corruption or data loss.

e si verifica in questo punto del codice:
Codice sorgente - presumibilmente C++

  1. [CODE]
  2.  private void Form1_FormClosing(object sender, FormClosingEventArgs e)
  3.         {
  4.             if (e.CloseReason == CloseReason.UserClosing)
  5.             {
  6.                 try
  7.                 {
  8.                     Form1.deviceAI.Dispose();
  9.                     Form1.deviceDIO.Dispose();
  10.                     TimerGiriMotore.Dispose();
  11.                     TimerPressione.Dispose();
  12.                     StartTh.Abort();
  13.                 }
  14.                 catch
  15.                 {
  16.  
  17.                 }
  18.                 finally
  19.                 {
  20.                     Application.Exit();
  21.                 }
  22.                 }
  23.  
  24. [/CODE]


In particolare qui:

Form1.deviceAI.Dispose();
Form1.deviceDIO.Dispose();

L'errore non si verifica sempre.

Sačreste aiutarmi? Grazie.

Ultima modifica effettuata da Sparvier0 il 21/06/2011 alle 1:21
PM
Avatar
HeDo (Founder Member)
Guru^2


Messaggi: 2765
Iscritto: 21/09/2007

Up
1
Down
V
Segnala al moderatore
Postato alle 10:12
Martedė, 21/06/2011
prova ad invertire l'ordine delle istruzioni, č probabile che il thread usi quelle risorse e, seppur per qualche msec, glie le stai distruggendo mentre č in funzione:

Codice sorgente - presumibilmente Plain Text

  1. StartTh.Abort();
  2. TimerGiriMotore.Dispose();
  3. TimerPressione.Dispose();  
  4. Form1.deviceAI.Dispose();
  5. Form1.deviceDIO.Dispose();


Non funziona, ho letto che č un problema dovuto ai componenti COM, in effetti deviceAI e deviceDIO sono activex - Sparvier0 - 21/06/11 21:57
purtroppo senza ulteriori informazioni non posso aiutarti :( - HeDo - 22/06/11 01:40
PM