This is a multi-part message in MIME format.

------=_NextPart_000_0044_01C5B34D.F2BA8190
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

I have a very simple block of code with open a file in a thread
and for the life of me I have no idea, wonder if it's a 2.0 beta bug?

here is my sample (which open a file in a thread)
=3D=3D=3D
public void Open(string file)
{
Cursor =3D Cursors.WaitCursor;
new Thread(delegate()=20
{
RecipeFile rf =3D null;
try
{
rf =3D new RecipeFile(file, false, SetStatus);// is =
ThreadSafe, only independant data
SetStatus(strings.done); // is ThreadSafe
}
catch (ArgumentException e)
{
SetStatus(e.Message);// is ThreadSafe
}
catch (SQLiteException e)
{
SetStatus(e.Message);// is ThreadSafe
}
finally
{
// error happened here in GUI thread: Cursor =3D =
Cursors.Default; =3D>AccessViolationException
this.BeginInvoke(new InvokeDelegate(delegate() { this.Cursor =
=3D Cursors.Default; }));
}
if (IsDisposed)
return;
this.BeginInvoke(new InvokeDelegate(delegate() { RecipeFile =3D =
rf; }));
}
).Start();
}
=3D=3D=3D=3D




--=20
If you're in a war, instead of throwing a hand grenade at the enemy, =
throw one of those small pumpkins. Maybe it'll make everyone think how =
stupid war is, and while they are thinking, you can throw a real grenade =
at them.
Jack Handey.
------=_NextPart_000_0044_01C5B34D.F2BA8190
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Diso-8859-1">
<META content=3D"MSHTML 6.00.2900.2722" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY>
<DIV><FONT face=3DArial size=3D2>I have a very simple block of code with =
open a file=20
in a thread</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>and for the life of me I have no idea, =
wonder if=20
it's a 2.0 beta bug?</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>here is my sample (which open a file in =
a=20
thread)<BR>=3D=3D=3D</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT><FONT size=3D2>
<P></FONT><FONT color=3D#0000ff size=3D2>public</FONT><FONT size=3D2> =
</FONT><FONT=20
color=3D#0000ff size=3D2>void</FONT><FONT size=3D2> Open(</FONT><FONT =
color=3D#0000ff=20
size=3D2>string</FONT><FONT size=3D2> file)<BR></FONT><FONT=20
size=3D2>{<BR>&nbsp;&nbsp;&nbsp; </FONT><FONT color=3D#008080=20
size=3D2>Cursor</FONT><FONT size=3D2> =3D </FONT><FONT color=3D#008080=20
size=3D2>Cursors</FONT><FONT size=3D2>.WaitCursor;<BR></FONT><FONT =
color=3D#0000ff=20
size=3D2>&nbsp;&nbsp;&nbsp; new</FONT><FONT size=3D2> </FONT><FONT =
color=3D#008080=20
size=3D2>Thread</FONT><FONT size=3D2>(</FONT><FONT color=3D#0000ff=20
size=3D2>delegate</FONT><FONT size=3D2>(</FONT><FONT size=3D2>) =
<BR>&nbsp;&nbsp;&nbsp;=20
{<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </FONT><FONT =
color=3D#008080=20
size=3D2>RecipeFile</FONT><FONT size=3D2> rf =3D </FONT><FONT =
color=3D#0000ff=20
size=3D2>null</FONT><FONT size=3D2>;<BR></FONT><FONT color=3D#0000ff=20
size=3D2>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; try<BR></FONT><FONT=20
size=3D2>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {<BR>&nbsp;&nbsp;&nbsp;=20
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; rf =3D </FONT><FONT =
color=3D#0000ff=20
size=3D2>new</FONT><FONT size=3D2> </FONT><FONT color=3D#008080=20
size=3D2>RecipeFile</FONT><FONT size=3D2>(file, </FONT><FONT =
color=3D#0000ff=20
size=3D2>false</FONT><FONT size=3D2>, SetStatus);<FONT =
color=3D#ff0000>//=20
is&nbsp;ThreadSafe, only independant=20
data</FONT><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs=
p;&nbsp;=20
SetStatus(</FONT><FONT color=3D#008080 size=3D2>strings</FONT><FONT =
size=3D2>.done);=20
<FONT color=3D#ff0000>//=20
is&nbsp;ThreadSafe</FONT><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n=
bsp;}<BR></FONT><FONT=20
color=3D#0000ff size=3D2>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; =
catch</FONT><FONT=20
size=3D2> (</FONT><FONT color=3D#008080 =
size=3D2>ArgumentException</FONT><FONT size=3D2>=20
e)<BR>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {<BR>&nbsp;&nbsp;&nbsp;=20
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; SetStatus(e.Message);<FONT=20
color=3D#ff0000>//=20
is&nbsp;ThreadSafe</FONT><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
}<BR></FONT><FONT color=3D#0000ff size=3D2>&nbsp;&nbsp;&nbsp; =
&nbsp;&nbsp;&nbsp;=20
catch</FONT><FONT size=3D2> (</FONT><FONT color=3D#008080=20
size=3D2>SQLiteException</FONT><FONT size=3D2> e)<BR>&nbsp;&nbsp;&nbsp;=20
&nbsp;&nbsp;&nbsp; {<BR>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; =
&nbsp;&nbsp;&nbsp;=20
SetStatus(e.Message);<FONT color=3D#ff0000>//=20
is&nbsp;ThreadSafe</FONT><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
}<BR></FONT><FONT color=3D#0000ff size=3D2>&nbsp;&nbsp;&nbsp; =
&nbsp;&nbsp;&nbsp;=20
finally<BR></FONT><FONT size=3D2>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; =
{<BR><FONT=20
color=3D#ff0000>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; =
// error=20
happened&nbsp;here in GUI thread: Cursor&nbsp;=3D Cursors.Default;=20
=3D&gt;AccessViolationException<BR></FONT></FONT><FONT color=3D#0000ff=20
size=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs=
p;=20
this</FONT><FONT size=3D2>.BeginInvoke(</FONT><FONT color=3D#0000ff=20
size=3D2>new</FONT><FONT size=3D2> </FONT><FONT color=3D#008080=20
size=3D2>InvokeDelegate</FONT><FONT size=3D2>(</FONT><FONT =
color=3D#0000ff=20
size=3D2>delegate</FONT><FONT size=3D2>() { </FONT><FONT color=3D#0000ff =

size=3D2>this</FONT><FONT size=3D2>.Cursor =3D </FONT><FONT =
color=3D#008080=20
size=3D2>Cursors</FONT><FONT size=3D2>.Default; =
}));<BR>&nbsp;&nbsp;&nbsp;=20
&nbsp;&nbsp;&nbsp; }<BR></FONT><FONT color=3D#0000ff =
size=3D2>&nbsp;&nbsp;&nbsp;=20
&nbsp;&nbsp;&nbsp; if</FONT><FONT size=3D2> (IsDisposed)<BR></FONT><FONT =

color=3D#0000ff size=3D2>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; =
&nbsp;&nbsp;&nbsp;=20
return</FONT><FONT size=3D2>;<BR></FONT><FONT color=3D#0000ff=20
size=3D2>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; this</FONT><FONT=20
size=3D2>.BeginInvoke(</FONT><FONT color=3D#0000ff =
size=3D2>new</FONT><FONT size=3D2>=20
</FONT><FONT color=3D#008080 size=3D2>InvokeDelegate</FONT><FONT=20
size=3D2>(</FONT><FONT color=3D#0000ff size=3D2>delegate</FONT><FONT =
size=3D2>() {=20
</FONT><FONT color=3D#008080 size=3D2>RecipeFile</FONT><FONT size=3D2> =
=3D rf;=20
}));<BR>&nbsp;&nbsp;&nbsp;&nbsp;}<BR>&nbsp;&nbsp;&nbsp;=20
).Start();<BR>}<BR></FONT><FONT face=3DArial =
size=3D2>=3D=3D=3D=3D</FONT></P></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><BR><FONT face=3DArial size=3D2>-- <BR>If you're in a war, instead =
of throwing=20
a hand grenade at the enemy, throw one of those small pumpkins. Maybe =
it'll make=20
everyone think how stupid war is, and while they are thinking, you can =
throw a=20
real grenade at them.<BR>Jack Handey.</FONT></DIV></BODY></HTML>

------=_NextPart_000_0044_01C5B34D.F2BA8190--

Re: problem with threading & nested anonymous method by Willy

Willy
Tue Sep 06 12:49:40 CDT 2005

This is a multi-part message in MIME format.

------=_NextPart_000_0199_01C5B31C.1F3636B0
Content-Type: text/plain;
charset="iso-8859-15"
Content-Transfer-Encoding: quoted-printable

What exact version og the framework are you running?
This works for me using 2.0.50727.

Willy.


"Lloyd Dupont" <ld@NewsAccount.galador.net> wrote in message =
news:uJk%23govsFHA.3216@TK2MSFTNGP12.phx.gbl...
I have a very simple block of code with open a file in a thread
and for the life of me I have no idea, wonder if it's a 2.0 beta bug?

here is my sample (which open a file in a thread)
=3D=3D=3D
public void Open(string file)
{
Cursor =3D Cursors.WaitCursor;
new Thread(delegate()=20
{
RecipeFile rf =3D null;
try
{
rf =3D new RecipeFile(file, false, SetStatus);// is =
ThreadSafe, only independant data
SetStatus(strings.done); // is ThreadSafe
}
catch (ArgumentException e)
{
SetStatus(e.Message);// is ThreadSafe
}
catch (SQLiteException e)
{
SetStatus(e.Message);// is ThreadSafe
}
finally
{
// error happened here in GUI thread: Cursor =3D =
Cursors.Default; =3D>AccessViolationException
this.BeginInvoke(new InvokeDelegate(delegate() { =
this.Cursor =3D Cursors.Default; }));
}
if (IsDisposed)
return;
this.BeginInvoke(new InvokeDelegate(delegate() { RecipeFile =
=3D rf; }));
}
).Start();
}
=3D=3D=3D=3D




--=20
If you're in a war, instead of throwing a hand grenade at the enemy, =
throw one of those small pumpkins. Maybe it'll make everyone think how =
stupid war is, and while they are thinking, you can throw a real grenade =
at them.
Jack Handey.
------=_NextPart_000_0199_01C5B31C.1F3636B0
Content-Type: text/html;
charset="iso-8859-15"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Diso-8859-15">
<META content=3D"MSHTML 6.00.2900.2722" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT face=3DTahoma size=3D2>What exact version og the framework =
are you=20
running?</FONT></DIV>
<DIV><FONT face=3DTahoma size=3D2>This works for me using =
2.0.50727.</FONT></DIV>
<DIV><FONT face=3DTahoma size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DTahoma size=3D2>Willy.</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV>"Lloyd Dupont" &lt;<A=20
href=3D"mailto:ld@NewsAccount.galador.net">ld@NewsAccount.galador.net</A>=
&gt;=20
wrote in message <A=20
href=3D"news:uJk%23govsFHA.3216@TK2MSFTNGP12.phx.gbl">news:uJk%23govsFHA.=
3216@TK2MSFTNGP12.phx.gbl</A>...</DIV>
<BLOCKQUOTE dir=3Dltr=20
style=3D"PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; =
BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
<DIV><FONT face=3DArial size=3D2>I have a very simple block of code =
with open a=20
file in a thread</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>and for the life of me I have no =
idea, wonder if=20
it's a 2.0 beta bug?</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>here is my sample (which open a file =
in a=20
thread)<BR>=3D=3D=3D</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT><FONT size=3D2>
<P></FONT><FONT color=3D#0000ff size=3D2>public</FONT><FONT size=3D2> =
</FONT><FONT=20
color=3D#0000ff size=3D2>void</FONT><FONT size=3D2> Open(</FONT><FONT =
color=3D#0000ff=20
size=3D2>string</FONT><FONT size=3D2> file)<BR></FONT><FONT=20
size=3D2>{<BR>&nbsp;&nbsp;&nbsp; </FONT><FONT color=3D#008080=20
size=3D2>Cursor</FONT><FONT size=3D2> =3D </FONT><FONT color=3D#008080 =

size=3D2>Cursors</FONT><FONT size=3D2>.WaitCursor;<BR></FONT><FONT =
color=3D#0000ff=20
size=3D2>&nbsp;&nbsp;&nbsp; new</FONT><FONT size=3D2> </FONT><FONT =
color=3D#008080=20
size=3D2>Thread</FONT><FONT size=3D2>(</FONT><FONT color=3D#0000ff=20
size=3D2>delegate</FONT><FONT size=3D2>(</FONT><FONT size=3D2>)=20
<BR>&nbsp;&nbsp;&nbsp; {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =

</FONT><FONT color=3D#008080 size=3D2>RecipeFile</FONT><FONT size=3D2> =
rf =3D=20
</FONT><FONT color=3D#0000ff size=3D2>null</FONT><FONT =
size=3D2>;<BR></FONT><FONT=20
color=3D#0000ff size=3D2>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; =
try<BR></FONT><FONT=20
size=3D2>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {<BR>&nbsp;&nbsp;&nbsp; =

&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; rf =3D </FONT><FONT =
color=3D#0000ff=20
size=3D2>new</FONT><FONT size=3D2> </FONT><FONT color=3D#008080=20
size=3D2>RecipeFile</FONT><FONT size=3D2>(file, </FONT><FONT =
color=3D#0000ff=20
size=3D2>false</FONT><FONT size=3D2>, SetStatus);<FONT =
color=3D#ff0000>//=20
is&nbsp;ThreadSafe, only independant=20
=
data</FONT><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs=
p;&nbsp;=20
SetStatus(</FONT><FONT color=3D#008080 size=3D2>strings</FONT><FONT =
size=3D2>.done);=20
<FONT color=3D#ff0000>//=20
=
is&nbsp;ThreadSafe</FONT><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n=
bsp;}<BR></FONT><FONT=20
color=3D#0000ff size=3D2>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; =
catch</FONT><FONT=20
size=3D2> (</FONT><FONT color=3D#008080 =
size=3D2>ArgumentException</FONT><FONT=20
size=3D2> e)<BR>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; =
{<BR>&nbsp;&nbsp;&nbsp;=20
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; SetStatus(e.Message);<FONT=20
color=3D#ff0000>//=20
=
is&nbsp;ThreadSafe</FONT><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
}<BR></FONT><FONT color=3D#0000ff size=3D2>&nbsp;&nbsp;&nbsp; =
&nbsp;&nbsp;&nbsp;=20
catch</FONT><FONT size=3D2> (</FONT><FONT color=3D#008080=20
size=3D2>SQLiteException</FONT><FONT size=3D2> =
e)<BR>&nbsp;&nbsp;&nbsp;=20
&nbsp;&nbsp;&nbsp; {<BR>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;=20
&nbsp;&nbsp;&nbsp; SetStatus(e.Message);<FONT color=3D#ff0000>//=20
=
is&nbsp;ThreadSafe</FONT><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
}<BR></FONT><FONT color=3D#0000ff size=3D2>&nbsp;&nbsp;&nbsp; =
&nbsp;&nbsp;&nbsp;=20
finally<BR></FONT><FONT size=3D2>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; =

{<BR><FONT color=3D#ff0000>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;=20
&nbsp;&nbsp;&nbsp; // error happened&nbsp;here in GUI thread: =
Cursor&nbsp;=3D=20
Cursors.Default; =
=3D&gt;AccessViolationException<BR></FONT></FONT><FONT=20
color=3D#0000ff=20
=
size=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs=
p;=20
this</FONT><FONT size=3D2>.BeginInvoke(</FONT><FONT color=3D#0000ff=20
size=3D2>new</FONT><FONT size=3D2> </FONT><FONT color=3D#008080=20
size=3D2>InvokeDelegate</FONT><FONT size=3D2>(</FONT><FONT =
color=3D#0000ff=20
size=3D2>delegate</FONT><FONT size=3D2>() { </FONT><FONT =
color=3D#0000ff=20
size=3D2>this</FONT><FONT size=3D2>.Cursor =3D </FONT><FONT =
color=3D#008080=20
size=3D2>Cursors</FONT><FONT size=3D2>.Default; =
}));<BR>&nbsp;&nbsp;&nbsp;=20
&nbsp;&nbsp;&nbsp; }<BR></FONT><FONT color=3D#0000ff =
size=3D2>&nbsp;&nbsp;&nbsp;=20
&nbsp;&nbsp;&nbsp; if</FONT><FONT size=3D2> =
(IsDisposed)<BR></FONT><FONT=20
color=3D#0000ff size=3D2>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; =
&nbsp;&nbsp;&nbsp;=20
return</FONT><FONT size=3D2>;<BR></FONT><FONT color=3D#0000ff=20
size=3D2>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; this</FONT><FONT=20
size=3D2>.BeginInvoke(</FONT><FONT color=3D#0000ff =
size=3D2>new</FONT><FONT size=3D2>=20
</FONT><FONT color=3D#008080 size=3D2>InvokeDelegate</FONT><FONT=20
size=3D2>(</FONT><FONT color=3D#0000ff size=3D2>delegate</FONT><FONT =
size=3D2>() {=20
</FONT><FONT color=3D#008080 size=3D2>RecipeFile</FONT><FONT size=3D2> =
=3D rf;=20
}));<BR>&nbsp;&nbsp;&nbsp;&nbsp;}<BR>&nbsp;&nbsp;&nbsp;=20
).Start();<BR>}<BR></FONT><FONT face=3DArial =
size=3D2>=3D=3D=3D=3D</FONT></P></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><BR><FONT face=3DArial size=3D2>-- <BR>If you're in a war, =
instead of=20
throwing a hand grenade at the enemy, throw one of those small =
pumpkins. Maybe=20
it'll make everyone think how stupid war is, and while they are =
thinking, you=20
can throw a real grenade at them.<BR>Jack=20
Handey.</FONT></DIV></BLOCKQUOTE></BODY></HTML>

------=_NextPart_000_0199_01C5B31C.1F3636B0--


Re: problem with threading & nested anonymous method by Lloyd

Lloyd
Tue Sep 06 18:25:12 CDT 2005

This is a multi-part message in MIME format.

------=_NextPart_000_0037_01C5B38E.0C3428C0
Content-Type: text/plain;
charset="iso-8859-15"
Content-Transfer-Encoding: quoted-printable

mmhh.. :-/
good to know at least !!!
I will tell you more tonight when I'll be on my home project again ;-)
"Willy Denoyette [MVP]" <willy.denoyette@telenet.be> wrote in message =
news:%23ioFdtwsFHA.3040@TK2MSFTNGP14.phx.gbl...
What exact version og the framework are you running?
This works for me using 2.0.50727.

Willy.


"Lloyd Dupont" <ld@NewsAccount.galador.net> wrote in message =
news:uJk%23govsFHA.3216@TK2MSFTNGP12.phx.gbl...
I have a very simple block of code with open a file in a thread
and for the life of me I have no idea, wonder if it's a 2.0 beta =
bug?

here is my sample (which open a file in a thread)
=3D=3D=3D
public void Open(string file)
{
Cursor =3D Cursors.WaitCursor;
new Thread(delegate()=20
{
RecipeFile rf =3D null;
try
{
rf =3D new RecipeFile(file, false, SetStatus);// is =
ThreadSafe, only independant data
SetStatus(strings.done); // is ThreadSafe
}
catch (ArgumentException e)
{
SetStatus(e.Message);// is ThreadSafe
}
catch (SQLiteException e)
{
SetStatus(e.Message);// is ThreadSafe
}
finally
{
// error happened here in GUI thread: Cursor =3D =
Cursors.Default; =3D>AccessViolationException
this.BeginInvoke(new InvokeDelegate(delegate() { =
this.Cursor =3D Cursors.Default; }));
}
if (IsDisposed)
return;
this.BeginInvoke(new InvokeDelegate(delegate() { RecipeFile =
=3D rf; }));
}
).Start();
}
=3D=3D=3D=3D




--=20
If you're in a war, instead of throwing a hand grenade at the enemy, =
throw one of those small pumpkins. Maybe it'll make everyone think how =
stupid war is, and while they are thinking, you can throw a real grenade =
at them.
Jack Handey.
------=_NextPart_000_0037_01C5B38E.0C3428C0
Content-Type: text/html;
charset="iso-8859-15"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Diso-8859-15">
<META content=3D"MSHTML 6.00.2900.2722" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT face=3DArial size=3D2>mmhh.. :-/</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>good to know at least !!!</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>I will tell you more tonight when I'll =
be on my=20
home project again ;-)</FONT></DIV>
<BLOCKQUOTE dir=3Dltr=20
style=3D"PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; =
BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
<DIV>"Willy Denoyette [MVP]" &lt;<A=20
=
href=3D"mailto:willy.denoyette@telenet.be">willy.denoyette@telenet.be</A>=
&gt;=20
wrote in message <A=20
=
href=3D"news:%23ioFdtwsFHA.3040@TK2MSFTNGP14.phx.gbl">news:%23ioFdtwsFHA.=
3040@TK2MSFTNGP14.phx.gbl</A>...</DIV>
<DIV><FONT face=3DTahoma size=3D2>What exact version og the framework =
are you=20
running?</FONT></DIV>
<DIV><FONT face=3DTahoma size=3D2>This works for me using =
2.0.50727.</FONT></DIV>
<DIV><FONT face=3DTahoma size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DTahoma size=3D2>Willy.</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV>"Lloyd Dupont" &lt;<A=20
=
href=3D"mailto:ld@NewsAccount.galador.net">ld@NewsAccount.galador.net</A>=
&gt;=20
wrote in message <A=20
=
href=3D"news:uJk%23govsFHA.3216@TK2MSFTNGP12.phx.gbl">news:uJk%23govsFHA.=
3216@TK2MSFTNGP12.phx.gbl</A>...</DIV>
<BLOCKQUOTE dir=3Dltr=20
style=3D"PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; =
BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
<DIV><FONT face=3DArial size=3D2>I have a very simple block of code =
with open a=20
file in a thread</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>and for the life of me I have no =
idea, wonder=20
if it's a 2.0 beta bug?</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>here is my sample (which open a =
file in a=20
thread)<BR>=3D=3D=3D</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT><FONT size=3D2>
<P></FONT><FONT color=3D#0000ff size=3D2>public</FONT><FONT =
size=3D2> </FONT><FONT=20
color=3D#0000ff size=3D2>void</FONT><FONT size=3D2> =
Open(</FONT><FONT=20
color=3D#0000ff size=3D2>string</FONT><FONT size=3D2> =
file)<BR></FONT><FONT=20
size=3D2>{<BR>&nbsp;&nbsp;&nbsp; </FONT><FONT color=3D#008080=20
size=3D2>Cursor</FONT><FONT size=3D2> =3D </FONT><FONT =
color=3D#008080=20
size=3D2>Cursors</FONT><FONT size=3D2>.WaitCursor;<BR></FONT><FONT =
color=3D#0000ff=20
size=3D2>&nbsp;&nbsp;&nbsp; new</FONT><FONT size=3D2> </FONT><FONT =
color=3D#008080=20
size=3D2>Thread</FONT><FONT size=3D2>(</FONT><FONT color=3D#0000ff=20
size=3D2>delegate</FONT><FONT size=3D2>(</FONT><FONT size=3D2>)=20
<BR>&nbsp;&nbsp;&nbsp; =
{<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
</FONT><FONT color=3D#008080 size=3D2>RecipeFile</FONT><FONT =
size=3D2> rf =3D=20
</FONT><FONT color=3D#0000ff size=3D2>null</FONT><FONT =
size=3D2>;<BR></FONT><FONT=20
color=3D#0000ff size=3D2>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;=20
try<BR></FONT><FONT size=3D2>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;=20
{<BR>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; rf =3D =

</FONT><FONT color=3D#0000ff size=3D2>new</FONT><FONT size=3D2> =
</FONT><FONT=20
color=3D#008080 size=3D2>RecipeFile</FONT><FONT size=3D2>(file, =
</FONT><FONT=20
color=3D#0000ff size=3D2>false</FONT><FONT size=3D2>, =
SetStatus);<FONT=20
color=3D#ff0000>// is&nbsp;ThreadSafe, only independant=20
=
data</FONT><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs=
p;&nbsp;=20
SetStatus(</FONT><FONT color=3D#008080 size=3D2>strings</FONT><FONT=20
size=3D2>.done); <FONT color=3D#ff0000>//=20
=
is&nbsp;ThreadSafe</FONT><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n=
bsp;}<BR></FONT><FONT=20
color=3D#0000ff size=3D2>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; =
catch</FONT><FONT=20
size=3D2> (</FONT><FONT color=3D#008080 =
size=3D2>ArgumentException</FONT><FONT=20
size=3D2> e)<BR>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; =
{<BR>&nbsp;&nbsp;&nbsp;=20
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; SetStatus(e.Message);<FONT=20
color=3D#ff0000>//=20
=
is&nbsp;ThreadSafe</FONT><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
}<BR></FONT><FONT color=3D#0000ff size=3D2>&nbsp;&nbsp;&nbsp; =
&nbsp;&nbsp;&nbsp;=20
catch</FONT><FONT size=3D2> (</FONT><FONT color=3D#008080=20
size=3D2>SQLiteException</FONT><FONT size=3D2> =
e)<BR>&nbsp;&nbsp;&nbsp;=20
&nbsp;&nbsp;&nbsp; {<BR>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;=20
&nbsp;&nbsp;&nbsp; SetStatus(e.Message);<FONT color=3D#ff0000>//=20
=
is&nbsp;ThreadSafe</FONT><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
}<BR></FONT><FONT color=3D#0000ff size=3D2>&nbsp;&nbsp;&nbsp; =
&nbsp;&nbsp;&nbsp;=20
finally<BR></FONT><FONT size=3D2>&nbsp;&nbsp;&nbsp; =
&nbsp;&nbsp;&nbsp;=20
{<BR><FONT color=3D#ff0000>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;=20
&nbsp;&nbsp;&nbsp; // error happened&nbsp;here in GUI thread: =
Cursor&nbsp;=3D=20
Cursors.Default; =
=3D&gt;AccessViolationException<BR></FONT></FONT><FONT=20
color=3D#0000ff=20
=
size=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs=
p;=20
this</FONT><FONT size=3D2>.BeginInvoke(</FONT><FONT color=3D#0000ff=20
size=3D2>new</FONT><FONT size=3D2> </FONT><FONT color=3D#008080=20
size=3D2>InvokeDelegate</FONT><FONT size=3D2>(</FONT><FONT =
color=3D#0000ff=20
size=3D2>delegate</FONT><FONT size=3D2>() { </FONT><FONT =
color=3D#0000ff=20
size=3D2>this</FONT><FONT size=3D2>.Cursor =3D </FONT><FONT =
color=3D#008080=20
size=3D2>Cursors</FONT><FONT size=3D2>.Default; =
}));<BR>&nbsp;&nbsp;&nbsp;=20
&nbsp;&nbsp;&nbsp; }<BR></FONT><FONT color=3D#0000ff =
size=3D2>&nbsp;&nbsp;&nbsp;=20
&nbsp;&nbsp;&nbsp; if</FONT><FONT size=3D2> =
(IsDisposed)<BR></FONT><FONT=20
color=3D#0000ff size=3D2>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;=20
&nbsp;&nbsp;&nbsp; return</FONT><FONT size=3D2>;<BR></FONT><FONT =
color=3D#0000ff=20
size=3D2>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; this</FONT><FONT=20
size=3D2>.BeginInvoke(</FONT><FONT color=3D#0000ff =
size=3D2>new</FONT><FONT=20
size=3D2> </FONT><FONT color=3D#008080 =
size=3D2>InvokeDelegate</FONT><FONT=20
size=3D2>(</FONT><FONT color=3D#0000ff size=3D2>delegate</FONT><FONT =
size=3D2>() {=20
</FONT><FONT color=3D#008080 size=3D2>RecipeFile</FONT><FONT =
size=3D2> =3D rf;=20
}));<BR>&nbsp;&nbsp;&nbsp;&nbsp;}<BR>&nbsp;&nbsp;&nbsp;=20
).Start();<BR>}<BR></FONT><FONT face=3DArial =
size=3D2>=3D=3D=3D=3D</FONT></P></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><BR><FONT face=3DArial size=3D2>-- <BR>If you're in a war, =
instead of=20
throwing a hand grenade at the enemy, throw one of those small =
pumpkins.=20
Maybe it'll make everyone think how stupid war is, and while they =
are=20
thinking, you can throw a real grenade at them.<BR>Jack=20
Handey.</FONT></DIV></BLOCKQUOTE></BLOCKQUOTE></BODY></HTML>

------=_NextPart_000_0037_01C5B38E.0C3428C0--


Re: problem with threading & nested anonymous method by Lloyd

Lloyd
Wed Sep 07 10:18:44 CDT 2005

This is a multi-part message in MIME format.

------=_NextPart_000_004E_01C5B413.41368EC0
Content-Type: text/plain;
charset="iso-8859-15"
Content-Transfer-Encoding: quoted-printable

mmhh.....
progress here.... the anonymous inner method are simple bugged!!!
and the proof below!!!!
there is code, only very slightly different, and one is crashing and not =
the other.
the difference is subtle anonymous inner class stuff.....


=3D=3D=3D=3D=3D=3D=3D=3D=3D Working version =
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
public void Open(string file)
{
Cursor =3D Cursors.WaitCursor;
string doneMsg =3D strings.done; // initialize for Thread safety
new Thread(delegate()
{
try
{
RecipeFile rf =3D new RecipeFile(file, false, SetStatus); // =
variable declared & used in the same block
SetStatus(doneMsg);
if (!IsDisposed)
BeginInvoke(new InvokeDelegate(delegate()
{
RecipeFile =3D rf; // used in this other anonymous =
method & thread
}));
}
catch (ArgumentException e) { SetStatus(e.Message); }
catch (SQLiteException e) { SetStatus(e.Message); }
finally
{
if (!IsDisposed)
BeginInvoke(new InvokeDelegate(delegate() { Cursor =3D =
Cursors.Default; }));
}
}
).Start();
}
=3D=3D=3D=3D=3D=3D=3D=3D=3D Crashing version =
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
public void Open(string file)
{
Cursor =3D Cursors.WaitCursor;
string doneMsg =3D strings.done; // initialize for Thread safety
new Thread(delegate()
{
RecipeFile rf; // variable declared here
try
{
rf =3D new RecipeFile(file, false, SetStatus);
SetStatus(doneMsg);
if (!IsDisposed)
BeginInvoke(new InvokeDelegate(delegate()
{
RecipeFile =3D rf; // used in this other anonymous =
method & thread
}));
}
catch (ArgumentException e) { SetStatus(e.Message); }
catch (SQLiteException e) { SetStatus(e.Message); }
finally
{
if (!IsDisposed)
BeginInvoke(new InvokeDelegate(delegate() { Cursor =3D =
Cursors.Default; }));
}
}
).Start();
}
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D



--=20
If you're in a war, instead of throwing a hand grenade at the enemy, =
throw one of those small pumpkins. Maybe it'll make everyone think how =
stupid war is, and while they are thinking, you can throw a real grenade =
at them.
Jack Handey.
"Willy Denoyette [MVP]" <willy.denoyette@telenet.be> wrote in message =
news:%23ioFdtwsFHA.3040@TK2MSFTNGP14.phx.gbl...
What exact version og the framework are you running?
This works for me using 2.0.50727.

Willy.


"Lloyd Dupont" <ld@NewsAccount.galador.net> wrote in message =
news:uJk%23govsFHA.3216@TK2MSFTNGP12.phx.gbl...
I have a very simple block of code with open a file in a thread
and for the life of me I have no idea, wonder if it's a 2.0 beta =
bug?

here is my sample (which open a file in a thread)
=3D=3D=3D
public void Open(string file)
{
Cursor =3D Cursors.WaitCursor;
new Thread(delegate()=20
{
RecipeFile rf =3D null;
try
{
rf =3D new RecipeFile(file, false, SetStatus);// is =
ThreadSafe, only independant data
SetStatus(strings.done); // is ThreadSafe
}
catch (ArgumentException e)
{
SetStatus(e.Message);// is ThreadSafe
}
catch (SQLiteException e)
{
SetStatus(e.Message);// is ThreadSafe
}
finally
{
// error happened here in GUI thread: Cursor =3D =
Cursors.Default; =3D>AccessViolationException
this.BeginInvoke(new InvokeDelegate(delegate() { =
this.Cursor =3D Cursors.Default; }));
}
if (IsDisposed)
return;
this.BeginInvoke(new InvokeDelegate(delegate() { RecipeFile =
=3D rf; }));
}
).Start();
}
=3D=3D=3D=3D




--=20
If you're in a war, instead of throwing a hand grenade at the enemy, =
throw one of those small pumpkins. Maybe it'll make everyone think how =
stupid war is, and while they are thinking, you can throw a real grenade =
at them.
Jack Handey.
------=_NextPart_000_004E_01C5B413.41368EC0
Content-Type: text/html;
charset="iso-8859-15"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Diso-8859-15">
<META content=3D"MSHTML 6.00.2900.2722" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT face=3DArial size=3D2>mmhh.....</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>progress here.... the anonymous inner =
method are=20
simple bugged!!!</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>and the proof below!!!!</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>there is code, only very slightly =
different, and=20
one is crashing and not the other.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>the difference is subtle anonymous =
inner class=20
stuff.....</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>=3D=3D=3D=3D=3D=3D=3D=3D=3D <FONT =
color=3D#800000>Working=20
version</FONT> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D<BR></FONT><FONT =
color=3D#0000ff=20
size=3D2>public</FONT><FONT size=3D2> </FONT><FONT color=3D#0000ff=20
size=3D2>void</FONT><FONT size=3D2> Open(</FONT><FONT color=3D#0000ff=20
size=3D2>string</FONT><FONT size=3D2> file)<BR>{<BR></FONT><FONT =
color=3D#008080=20
size=3D2>&nbsp;&nbsp;&nbsp; Cursor</FONT><FONT size=3D2> =3D =
</FONT><FONT=20
color=3D#008080 size=3D2>Cursors</FONT><FONT =
size=3D2>.WaitCursor;<BR></FONT><FONT=20
color=3D#0000ff size=3D2>&nbsp;&nbsp;&nbsp; string</FONT><FONT size=3D2> =
doneMsg =3D=20
</FONT><FONT color=3D#008080 size=3D2>strings</FONT><FONT =
size=3D2>.done; </FONT><FONT=20
color=3D#808080 size=3D2>// initialize for Thread safety<BR></FONT><FONT =

color=3D#0000ff size=3D2>&nbsp;&nbsp;&nbsp; new</FONT><FONT size=3D2> =
</FONT><FONT=20
color=3D#008080 size=3D2>Thread</FONT><FONT size=3D2>(</FONT><FONT =
color=3D#0000ff=20
size=3D2>delegate</FONT><FONT size=3D2>()<BR>&nbsp;&nbsp;&nbsp; =
{<BR></FONT><FONT=20
color=3D#0000ff size=3D2>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; =
try<BR></FONT><FONT=20
size=3D2>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {<BR></FONT><FONT =
color=3D#008080=20
size=3D2>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;=20
RecipeFile</FONT><FONT size=3D2> rf =3D </FONT><FONT color=3D#0000ff=20
size=3D2>new</FONT><FONT size=3D2> </FONT><FONT color=3D#008080=20
size=3D2>RecipeFile</FONT><FONT size=3D2>(file, </FONT><FONT =
color=3D#0000ff=20
size=3D2>false</FONT><FONT size=3D2>, SetStatus);<FONT color=3D#ff0000> =
// variable=20
declared &amp; used in the same=20
block</FONT><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb=
sp;&nbsp;=20
SetStatus(doneMsg);<BR></FONT><FONT color=3D#0000ff =
size=3D2>&nbsp;&nbsp;&nbsp;=20
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; if</FONT><FONT size=3D2>=20
(!IsDisposed)<BR>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; =
&nbsp;&nbsp;&nbsp;=20
&nbsp;&nbsp;&nbsp; BeginInvoke(</FONT><FONT color=3D#0000ff =
size=3D2>new</FONT><FONT=20
size=3D2> </FONT><FONT color=3D#008080 =
size=3D2>InvokeDelegate</FONT><FONT=20
size=3D2>(</FONT><FONT color=3D#0000ff size=3D2>delegate</FONT><FONT=20
size=3D2>()<BR>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;=20
&nbsp;&nbsp;&nbsp; {<BR></FONT><FONT color=3D#008080 =
size=3D2>&nbsp;&nbsp;&nbsp;=20
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; =
&nbsp;&nbsp;&nbsp;=20
RecipeFile</FONT><FONT size=3D2> =3D rf;<FONT color=3D#ff0000> // used =
in this other=20
anonymous method &amp;=20
thread<BR></FONT>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n=
bsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
}));<BR>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }<BR></FONT><FONT =
color=3D#0000ff=20
size=3D2>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; catch</FONT><FONT =
size=3D2>=20
(</FONT><FONT color=3D#008080 size=3D2>ArgumentException</FONT><FONT =
size=3D2>=20
e)&nbsp;{&nbsp;SetStatus(e.Message);&nbsp;}<BR></FONT><FONT =
color=3D#0000ff=20
size=3D2>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; catch</FONT><FONT =
size=3D2>=20
(</FONT><FONT color=3D#008080 size=3D2>SQLiteException</FONT><FONT =
size=3D2>=20
e)&nbsp;{&nbsp;SetStatus(e.Message); }<BR>&nbsp;&nbsp;&nbsp; =
&nbsp;&nbsp;&nbsp;=20
</FONT><FONT color=3D#0000ff size=3D2>finally<BR></FONT><FONT=20
size=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
{<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
</FONT><FONT color=3D#0000ff size=3D2>if</FONT><FONT size=3D2>=20
(!IsDisposed)<BR>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; =
&nbsp;&nbsp;&nbsp;=20
&nbsp;&nbsp;&nbsp; BeginInvoke(</FONT><FONT color=3D#0000ff =
size=3D2>new</FONT><FONT=20
size=3D2> </FONT><FONT color=3D#008080 =
size=3D2>InvokeDelegate</FONT><FONT=20
size=3D2>(</FONT><FONT color=3D#0000ff size=3D2>delegate</FONT><FONT =
size=3D2>() {=20
</FONT><FONT color=3D#008080 size=3D2>Cursor</FONT><FONT size=3D2> =3D =
</FONT><FONT=20
color=3D#008080 size=3D2>Cursors</FONT><FONT size=3D2>.Default;=20
}));<BR>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }<BR>&nbsp;&nbsp;&nbsp;=20
}<BR>&nbsp;&nbsp;&nbsp; ).Start();<BR>}</DIV></FONT>
<DIV><FONT face=3DArial size=3D2>=3D=3D=3D=3D=3D=3D=3D=3D=3D <FONT =
color=3D#800000>Crashing=20
version</FONT> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D<BR><FONT face=3D"Times =
New Roman"><FONT=20
color=3D#0000ff>public</FONT><FONT size=3D2> </FONT><FONT =
color=3D#0000ff=20
size=3D2>void</FONT><FONT size=3D2> Open(</FONT><FONT color=3D#0000ff=20
size=3D2>string</FONT></FONT><FONT face=3D"Times New Roman"><FONT =
size=3D2>=20
file)<BR>{<BR></FONT><FONT color=3D#008080 size=3D2>&nbsp;&nbsp;&nbsp;=20
Cursor</FONT><FONT size=3D2> =3D </FONT><FONT color=3D#008080=20
size=3D2>Cursors</FONT></FONT><FONT face=3D"Times New Roman"><FONT=20
size=3D2>.WaitCursor;<BR></FONT><FONT color=3D#0000ff =
size=3D2>&nbsp;&nbsp;&nbsp;=20
string</FONT><FONT size=3D2> doneMsg =3D </FONT><FONT color=3D#008080=20
size=3D2>strings</FONT><FONT size=3D2>.done; </FONT></FONT><FONT=20
face=3D"Times New Roman"><FONT color=3D#808080 size=3D2>// initialize =
for Thread=20
safety<BR></FONT><FONT color=3D#0000ff size=3D2>&nbsp;&nbsp;&nbsp; =
new</FONT><FONT=20
size=3D2> </FONT><FONT color=3D#008080 size=3D2>Thread</FONT><FONT=20
size=3D2>(</FONT><FONT color=3D#0000ff =
size=3D2>delegate</FONT></FONT><FONT=20
face=3D"Times New Roman" size=3D2>()<BR>&nbsp;&nbsp;&nbsp; =
{<BR></FONT><FONT=20
face=3D"Times New Roman" color=3D#0000ff size=3D2><FONT=20
color=3D#008080>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;RecipeFil=
e</FONT><FONT=20
color=3D#000000 size=3D2> rf; <FONT color=3D#ff0000>// variable declared =

here</FONT></FONT><FONT face=3D"Times New Roman"><FONT=20
size=3D2><BR></FONT></FONT>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
try<BR></FONT><FONT face=3D"Times New Roman"><FONT =
size=3D2>&nbsp;&nbsp;&nbsp;=20
&nbsp;&nbsp;&nbsp; {<BR></FONT><FONT color=3D#008080=20
size=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs=
p;=20
</FONT><FONT size=3D2>rf =3D </FONT><FONT color=3D#0000ff =
size=3D2>new</FONT><FONT=20
size=3D2> </FONT><FONT color=3D#008080 size=3D2>RecipeFile</FONT><FONT =
size=3D2>(file,=20
</FONT><FONT color=3D#0000ff size=3D2>false</FONT></FONT><FONT=20
face=3D"Times New Roman"><FONT size=3D2>, =
SetStatus);</FONT></FONT></FONT></DIV>
<DIV><FONT face=3DArial size=3D2><FONT face=3D"Times New Roman"><FONT=20
size=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs=
p;=20
SetStatus(doneMsg);<BR></FONT><FONT color=3D#0000ff =
size=3D2>&nbsp;&nbsp;&nbsp;=20
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; if</FONT></FONT><FONT=20
face=3D"Times New Roman"><FONT size=3D2> =
(!IsDisposed)<BR>&nbsp;&nbsp;&nbsp;=20
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;=20
BeginInvoke(</FONT><FONT color=3D#0000ff size=3D2>new</FONT><FONT =
size=3D2>=20
</FONT><FONT color=3D#008080 size=3D2>InvokeDelegate</FONT><FONT=20
size=3D2>(</FONT><FONT color=3D#0000ff =
size=3D2>delegate</FONT></FONT><FONT=20
face=3D"Times New Roman"><FONT size=3D2>()<BR>&nbsp;&nbsp;&nbsp; =
&nbsp;&nbsp;&nbsp;=20
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {<BR></FONT><FONT color=3D#008080=20
size=3D2>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;=20
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; RecipeFile</FONT></FONT><FONT=20
face=3D"Times New Roman"><FONT size=3D2> =3D rf;<FONT color=3D#ff0000> =
// used in this=20
other anonymous method &amp;=20
thread</FONT><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n=
bsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
}));<BR>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }<BR></FONT><FONT =
color=3D#0000ff=20
size=3D2>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; catch</FONT><FONT =
size=3D2>=20
(</FONT><FONT color=3D#008080 =
size=3D2>ArgumentException</FONT></FONT><FONT=20
face=3D"Times New Roman"><FONT size=3D2>=20
e)&nbsp;{&nbsp;SetStatus(e.Message);&nbsp;}<BR></FONT><FONT =
color=3D#0000ff=20
size=3D2>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; catch</FONT><FONT =
size=3D2>=20
(</FONT><FONT color=3D#008080 =
size=3D2>SQLiteException</FONT></FONT><FONT=20
face=3D"Times New Roman" size=3D2> e)&nbsp;{&nbsp;SetStatus(e.Message);=20
}<BR>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; </FONT><FONT face=3D"Times =
New Roman"=20
color=3D#0000ff size=3D2>finally<BR></FONT><FONT face=3D"Times New =
Roman"><FONT=20
size=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
{<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
</FONT><FONT color=3D#0000ff size=3D2>if</FONT></FONT><FONT=20
face=3D"Times New Roman"><FONT size=3D2> =
(!IsDisposed)<BR>&nbsp;&nbsp;&nbsp;=20
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;=20
BeginInvoke(</FONT><FONT color=3D#0000ff size=3D2>new</FONT><FONT =
size=3D2>=20
</FONT><FONT color=3D#008080 size=3D2>InvokeDelegate</FONT><FONT=20
size=3D2>(</FONT><FONT color=3D#0000ff size=3D2>delegate</FONT><FONT =
size=3D2>() {=20
</FONT><FONT color=3D#008080 size=3D2>Cursor</FONT><FONT size=3D2> =3D =
</FONT><FONT=20
color=3D#008080 size=3D2>Cursors</FONT></FONT><FONT face=3D"Times New =
Roman"=20
size=3D2>.Default; }));<BR>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;=20
}<BR>&nbsp;&nbsp;&nbsp; }<BR>&nbsp;&nbsp;&nbsp;=20
).Start();<BR>}</FONT></FONT></DIV>
<DIV><FONT face=3DArial =
size=3D2>=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><BR>-- <BR>If you're in a war, instead of throwing a hand grenade =
at the=20
enemy, throw one of those small pumpkins. Maybe it'll make everyone =
think how=20
stupid war is, and while they are thinking, you can throw a real grenade =
at=20
them.<BR>Jack Handey.</DIV>
<BLOCKQUOTE dir=3Dltr=20
style=3D"PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; =
BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
<DIV>"Willy Denoyette [MVP]" &lt;<A=20
=
href=3D"mailto:willy.denoyette@telenet.be">willy.denoyette@telenet.be</A>=
&gt;=20
wrote in message <A=20
=
href=3D"news:%23ioFdtwsFHA.3040@TK2MSFTNGP14.phx.gbl">news:%23ioFdtwsFHA.=
3040@TK2MSFTNGP14.phx.gbl</A>...</DIV>
<DIV><FONT face=3DTahoma size=3D2>What exact version og the framework =
are you=20
running?</FONT></DIV>
<DIV><FONT face=3DTahoma size=3D2>This works for me using =
2.0.50727.</FONT></DIV>
<DIV><FONT face=3DTahoma size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DTahoma size=3D2>Willy.</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV>"Lloyd Dupont" &lt;<A=20
=
href=3D"mailto:ld@NewsAccount.galador.net">ld@NewsAccount.galador.net</A>=
&gt;=20
wrote in message <A=20
=
href=3D"news:uJk%23govsFHA.3216@TK2MSFTNGP12.phx.gbl">news:uJk%23govsFHA.=
3216@TK2MSFTNGP12.phx.gbl</A>...</DIV>
<BLOCKQUOTE dir=3Dltr=20
style=3D"PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; =
BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
<DIV><FONT face=3DArial size=3D2>I have a very simple block of code =
with open a=20
file in a thread</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>and for the life of me I have no =
idea, wonder=20
if it's a