<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Mein Thread schliesst sich nicht mehr]]></title><description><![CDATA[<p>Das Problem das ich mit der Datenbank hatte habe ich gelöst indem ich alle DB Zugriffe aus dem Thread ausgelagert habe.<br />
Nun bleibt aber aus irgendeinen Grund der Thread offen wenn das Programm beendet wird.</p>
<p>Mein Thread:</p>
<pre><code class="language-cpp">bool stop = false;
CAutofinderDlg * parent =(CAutofinderDlg *) pParam;
parent-&gt;sucht=true;
CString sql =&quot;Update Links set Color='160060060'  Where Color= '255000000'&quot;;
SendMessage(parent-&gt;GetSafeHwnd(),WM_DBEXECUTE,0,(long)&amp;sql);//Führt den SQL String aus
round++;
int c =0;
CWebGrab Grab;
round2 =0;
Field_Searcher fs;//Eine Klasse die einen Text nach Vorgaben aus der DB zerlegt und das Ergebnis in der DB speichert
Copy_Fieldsearcher(&amp;fs,&amp;parent-&gt;feldsucher);//Kopieren der Arrays mit Daten aus der DB in das Field_SearcherObject des Threads
int bin = parent-&gt;AA.GetSize();
CSingleLock lock2(&amp;agenten_lock, true);
for (int x =0;x&lt; parent-&gt;AA.GetSize();x++)
{		
 if(!(WaitForSingleObject(g_EventKill,0)==WAIT_TIMEOUT))
 {
  stop = true;	
  break;
 }
 if(parent-&gt;AA[x] != NULL&amp;&amp;parent-&gt;AA[x]-&gt;aktiv)
 {
  CString Url = parent-&gt;AA[x]-&gt;Url;
  parent-&gt;SetDlgItemText(IDC_CSPA,&quot;Aktueller Agent:&quot; + parent-&gt;AA[x]-&gt;Name);
  char buffer[6]; 
  _itoa(parent-&gt;AA[x]-&gt;Ag_Nr,buffer,10);
  lock2.Unlock();
  SetConfig(&quot;LastSp&quot;,buffer);
  lock2.Lock();
  if(parent-&gt;suche_1 == true)
  {
   fs.Add_Fields(1,parent-&gt;AA[x]-&gt;Sp_Nr,parent-&gt;AA[x]-&gt;Url,&amp;lock2,parent-&gt;AA[x]-&gt;use_empty_ez);
   SendMessage(parent-&gt;GetSafeHwnd(),WM_FILLLIST,0,0);//Füllt ein ListCtrl mit Daten aus der DB
  }
  if(parent-&gt;suche_2 == true)
  {
   fs.Add_Fields(2,parent-&gt;AA[x]-&gt;Sp_Nr,parent-&gt;AA[x]-&gt;Url_2,&amp;lock2,parent-&gt;AA[x]-&gt;use_empty_ez);
   SendMessage(parent-&gt;GetSafeHwnd(),WM_FILLLIST,0,0);
  }
 }
}
if(!stop)
{
 parent-&gt;sucht = false;
 parent-&gt;SetTimer(TIMER1,600,NULL);
}
else
{
 parent-&gt;KillTimer(TIMER1);
 parent-&gt;FindAutos_stop = true;
}
return FALSE;
}
</code></pre>
<p>OnDestroy:</p>
<pre><code class="language-cpp">g_EventKill.SetEvent();
Sleep(420000);
DB.force_close();
CHMXDialog::OnDestroy();
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/topic/51118/mein-thread-schliesst-sich-nicht-mehr</link><generator>RSS for Node</generator><lastBuildDate>Sun, 31 May 2026 11:36:10 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/51118.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 07 Oct 2003 12:25:07 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Mein Thread schliesst sich nicht mehr on Tue, 07 Oct 2003 12:25:52 GMT]]></title><description><![CDATA[<p>Das Problem das ich mit der Datenbank hatte habe ich gelöst indem ich alle DB Zugriffe aus dem Thread ausgelagert habe.<br />
Nun bleibt aber aus irgendeinen Grund der Thread offen wenn das Programm beendet wird.</p>
<p>Mein Thread:</p>
<pre><code class="language-cpp">bool stop = false;
CAutofinderDlg * parent =(CAutofinderDlg *) pParam;
parent-&gt;sucht=true;
CString sql =&quot;Update Links set Color='160060060'  Where Color= '255000000'&quot;;
SendMessage(parent-&gt;GetSafeHwnd(),WM_DBEXECUTE,0,(long)&amp;sql);//Führt den SQL String aus
round++;
int c =0;
CWebGrab Grab;
round2 =0;
Field_Searcher fs;//Eine Klasse die einen Text nach Vorgaben aus der DB zerlegt und das Ergebnis in der DB speichert
Copy_Fieldsearcher(&amp;fs,&amp;parent-&gt;feldsucher);//Kopieren der Arrays mit Daten aus der DB in das Field_SearcherObject des Threads
int bin = parent-&gt;AA.GetSize();
CSingleLock lock2(&amp;agenten_lock, true);
for (int x =0;x&lt; parent-&gt;AA.GetSize();x++)
{		
 if(!(WaitForSingleObject(g_EventKill,0)==WAIT_TIMEOUT))
 {
  stop = true;	
  break;
 }
 if(parent-&gt;AA[x] != NULL&amp;&amp;parent-&gt;AA[x]-&gt;aktiv)
 {
  CString Url = parent-&gt;AA[x]-&gt;Url;
  parent-&gt;SetDlgItemText(IDC_CSPA,&quot;Aktueller Agent:&quot; + parent-&gt;AA[x]-&gt;Name);
  char buffer[6]; 
  _itoa(parent-&gt;AA[x]-&gt;Ag_Nr,buffer,10);
  lock2.Unlock();
  SetConfig(&quot;LastSp&quot;,buffer);
  lock2.Lock();
  if(parent-&gt;suche_1 == true)
  {
   fs.Add_Fields(1,parent-&gt;AA[x]-&gt;Sp_Nr,parent-&gt;AA[x]-&gt;Url,&amp;lock2,parent-&gt;AA[x]-&gt;use_empty_ez);
   SendMessage(parent-&gt;GetSafeHwnd(),WM_FILLLIST,0,0);//Füllt ein ListCtrl mit Daten aus der DB
  }
  if(parent-&gt;suche_2 == true)
  {
   fs.Add_Fields(2,parent-&gt;AA[x]-&gt;Sp_Nr,parent-&gt;AA[x]-&gt;Url_2,&amp;lock2,parent-&gt;AA[x]-&gt;use_empty_ez);
   SendMessage(parent-&gt;GetSafeHwnd(),WM_FILLLIST,0,0);
  }
 }
}
if(!stop)
{
 parent-&gt;sucht = false;
 parent-&gt;SetTimer(TIMER1,600,NULL);
}
else
{
 parent-&gt;KillTimer(TIMER1);
 parent-&gt;FindAutos_stop = true;
}
return FALSE;
}
</code></pre>
<p>OnDestroy:</p>
<pre><code class="language-cpp">g_EventKill.SetEvent();
Sleep(420000);
DB.force_close();
CHMXDialog::OnDestroy();
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/367531</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/367531</guid><dc:creator><![CDATA[Andorxor]]></dc:creator><pubDate>Tue, 07 Oct 2003 12:25:52 GMT</pubDate></item><item><title><![CDATA[Reply to Mein Thread schliesst sich nicht mehr on Tue, 07 Oct 2003 14:48:43 GMT]]></title><description><![CDATA[<p>Ich habe Sleep und das Schliessen der Datenbank rausgenommen und jetzt läuft es.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/367699</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/367699</guid><dc:creator><![CDATA[Andorxor]]></dc:creator><pubDate>Tue, 07 Oct 2003 14:48:43 GMT</pubDate></item></channel></rss>