Hi,

I am making an async web service call and a progress bar that just loops
until the call is complete. Before I make the call I set a bool var to
false I the invoke the progress bar and while this var is false the bar
will continue to loop. When the call completes this var is set to true and
the progress bar is stopped and hidden. The probelm is that sometime it
crashes the emulator, however it has not yet crashed an actual pocket pc
device. As I am dealing with more than one thread I am using the Invoke
methods. The key code is included below:

private void btnDownloadSchedule_Click(object sender, System.EventArgs e)
{
this.btnDownloadSchedule.Enabled = false;
this.ShowProgressBar();
this.SetGotScheduleToFalse();

this.wsSchedule = new
Heat.IntelligentScheduler.Pda.App.wsHeatSchedule.Schedule();
this.wsSchedule.BeginGetSchedule(this.mScheduling.EngineerId,
this.GetDate().ToShortDateString(), wsHeatSchedule.JobPriority.All, new
AsyncCallback(ScheduleCallback), null);
}

private void ScheduleCallback(IAsyncResult iarSchedule)
{
try
{
this.wsSchedule.EndGetSchedule(iarSchedule, out this.xnHigh, out
this.xnAM, out this.xnPM);

this.mScheduling.AddScheduleData(this.xnHigh, JobPriority.All,
this.GetDate());
this.wsSchedule.Abort();

this.pbStatus.Invoke(new EventHandler(this.SetProgressMax));
this.SetGotScheduleToTrue();
this.HideProgressBar();
this.btnDownloadSchedule.Enabled = true;
}
catch(Exception ex)
{
MessageBoxes.ErrorMessageBox(ex.ToString(), "Here 2");
/*if(MessageBoxes.QuestionMessageBox("There ws a problem fulfilling your
last request, would you like to try again?", "Communication Failure : " +
ex.ToString()) == DialogResult.Yes)
{
//this.GetSchedule(DateTime.Parse(this.cboYear.SelectedValue.ToString()
+ "/" + this.cboMonth.SelectedValue.ToString() + "/" +
this.cboDay.SelectedValue.ToString()));
}*/
}
}

private DateTime GetDate()
{
return DateTime.Parse(this.cboYear.SelectedValue.ToString() + "/" +
this.cboMonth.SelectedValue.ToString() + "/" +
this.cboDay.SelectedValue.ToString());
}

public void UpdateProgressBar(object sender, EventArgs e)
{
while(!this.bolGotSchedule)
{
if(this.pbStatus.Value == this.pbStatus.Maximum)
{
this.pbStatus.Value = this.pbStatus.Minimum;
}

this.pbStatus.Value += 5;
Application.DoEvents();
}
}

public void SetProgressMax(object sender, EventArgs e)
{
this.pbStatus.Value = this.pbStatus.Maximum;
Application.DoEvents();
}

public void ShowProgressBar()
{
this.pbStatus.Invoke(new EventHandler(ShowProgressBar));
}

public void ShowProgressBar(object sender, EventArgs e)
{
this.pbStatus.Visible = true;
}

public void HideProgressBar()
{
this.pbStatus.Invoke(new EventHandler(HideProgressBar));
}

public void HideProgressBar(object sender, EventArgs e)
{
this.pbStatus.Visible = false;
}

public void SetGotScheduleToTrue()
{
this.Invoke(new EventHandler(SetGotScheduleToTrue));
}

public void SetGotScheduleToTrue(object sender, EventArgs e)
{
this.bolGotSchedule = true;
}

public void SetGotScheduleToFalse()
{
this.Invoke(new EventHandler(SetGotScheduleToFalse));
}

Although it has not crashed any devices, the app is still in development and
has not run that much on real devices. At the moment I think it is a glitch
with the emulator, but I would appreciate any feedback on the code.

Mark

Re: code crashes emulator by Alex

Alex
Sun Jul 11 23:36:33 CDT 2004

Crashes how? Do you get a fault inside the emulator code, emulated OS or
your own app?

"Mark Irvine" <markpirvine@hotmail.com> wrote in message
news:u5efjIqZEHA.2340@TK2MSFTNGP09.phx.gbl...
> Hi,
>
> I am making an async web service call and a progress bar that just loops
> until the call is complete. Before I make the call I set a bool var to
> false I the invoke the progress bar and while this var is false the bar
> will continue to loop. When the call completes this var is set to true
and
> the progress bar is stopped and hidden. The probelm is that sometime it
> crashes the emulator, however it has not yet crashed an actual pocket pc
> device. As I am dealing with more than one thread I am using the Invoke
> methods. The key code is included below:
>
> private void btnDownloadSchedule_Click(object sender, System.EventArgs e)
> {
> this.btnDownloadSchedule.Enabled = false;
> this.ShowProgressBar();
> this.SetGotScheduleToFalse();
>
> this.wsSchedule = new
> Heat.IntelligentScheduler.Pda.App.wsHeatSchedule.Schedule();
> this.wsSchedule.BeginGetSchedule(this.mScheduling.EngineerId,
> this.GetDate().ToShortDateString(), wsHeatSchedule.JobPriority.All, new
> AsyncCallback(ScheduleCallback), null);
> }
>
> private void ScheduleCallback(IAsyncResult iarSchedule)
> {
> try
> {
> this.wsSchedule.EndGetSchedule(iarSchedule, out this.xnHigh, out
> this.xnAM, out this.xnPM);
>
> this.mScheduling.AddScheduleData(this.xnHigh, JobPriority.All,
> this.GetDate());
> this.wsSchedule.Abort();
>
> this.pbStatus.Invoke(new EventHandler(this.SetProgressMax));
> this.SetGotScheduleToTrue();
> this.HideProgressBar();
> this.btnDownloadSchedule.Enabled = true;
> }
> catch(Exception ex)
> {
> MessageBoxes.ErrorMessageBox(ex.ToString(), "Here 2");
> /*if(MessageBoxes.QuestionMessageBox("There ws a problem fulfilling
your
> last request, would you like to try again?", "Communication Failure : " +
> ex.ToString()) == DialogResult.Yes)
> {
>
//this.GetSchedule(DateTime.Parse(this.cboYear.SelectedValue.ToString()
> + "/" + this.cboMonth.SelectedValue.ToString() + "/" +
> this.cboDay.SelectedValue.ToString()));
> }*/
> }
> }
>
> private DateTime GetDate()
> {
> return DateTime.Parse(this.cboYear.SelectedValue.ToString() + "/" +
> this.cboMonth.SelectedValue.ToString() + "/" +
> this.cboDay.SelectedValue.ToString());
> }
>
> public void UpdateProgressBar(object sender, EventArgs e)
> {
> while(!this.bolGotSchedule)
> {
> if(this.pbStatus.Value == this.pbStatus.Maximum)
> {
> this.pbStatus.Value = this.pbStatus.Minimum;
> }
>
> this.pbStatus.Value += 5;
> Application.DoEvents();
> }
> }
>
> public void SetProgressMax(object sender, EventArgs e)
> {
> this.pbStatus.Value = this.pbStatus.Maximum;
> Application.DoEvents();
> }
>
> public void ShowProgressBar()
> {
> this.pbStatus.Invoke(new EventHandler(ShowProgressBar));
> }
>
> public void ShowProgressBar(object sender, EventArgs e)
> {
> this.pbStatus.Visible = true;
> }
>
> public void HideProgressBar()
> {
> this.pbStatus.Invoke(new EventHandler(HideProgressBar));
> }
>
> public void HideProgressBar(object sender, EventArgs e)
> {
> this.pbStatus.Visible = false;
> }
>
> public void SetGotScheduleToTrue()
> {
> this.Invoke(new EventHandler(SetGotScheduleToTrue));
> }
>
> public void SetGotScheduleToTrue(object sender, EventArgs e)
> {
> this.bolGotSchedule = true;
> }
>
> public void SetGotScheduleToFalse()
> {
> this.Invoke(new EventHandler(SetGotScheduleToFalse));
> }
>
> Although it has not crashed any devices, the app is still in development
and
> has not run that much on real devices. At the moment I think it is a
glitch
> with the emulator, but I would appreciate any feedback on the code.
>
> Mark
>
>



Re: code crashes emulator by Mark

Mark
Mon Jul 12 04:20:32 CDT 2004

Alex,

Thanks for the reply. There is no error message. The app just stops
responding. The only way to get going again is to use the memory management
tool in settings or soft reset the emulator.

Mark

"Alex Feinman [MVP]" <public_news@alexfeinman.com> wrote in message
news:eMWKQn8ZEHA.2016@TK2MSFTNGP09.phx.gbl...
> Crashes how? Do you get a fault inside the emulator code, emulated OS or
> your own app?
>
> "Mark Irvine" <markpirvine@hotmail.com> wrote in message
> news:u5efjIqZEHA.2340@TK2MSFTNGP09.phx.gbl...
> > Hi,
> >
> > I am making an async web service call and a progress bar that just loops
> > until the call is complete. Before I make the call I set a bool var to
> > false I the invoke the progress bar and while this var is false the bar
> > will continue to loop. When the call completes this var is set to true
> and
> > the progress bar is stopped and hidden. The probelm is that sometime it
> > crashes the emulator, however it has not yet crashed an actual pocket pc
> > device. As I am dealing with more than one thread I am using the Invoke
> > methods. The key code is included below:
> >
> > private void btnDownloadSchedule_Click(object sender, System.EventArgs
e)
> > {
> > this.btnDownloadSchedule.Enabled = false;
> > this.ShowProgressBar();
> > this.SetGotScheduleToFalse();
> >
> > this.wsSchedule = new
> > Heat.IntelligentScheduler.Pda.App.wsHeatSchedule.Schedule();
> > this.wsSchedule.BeginGetSchedule(this.mScheduling.EngineerId,
> > this.GetDate().ToShortDateString(), wsHeatSchedule.JobPriority.All, new
> > AsyncCallback(ScheduleCallback), null);
> > }
> >
> > private void ScheduleCallback(IAsyncResult iarSchedule)
> > {
> > try
> > {
> > this.wsSchedule.EndGetSchedule(iarSchedule, out this.xnHigh, out
> > this.xnAM, out this.xnPM);
> >
> > this.mScheduling.AddScheduleData(this.xnHigh, JobPriority.All,
> > this.GetDate());
> > this.wsSchedule.Abort();
> >
> > this.pbStatus.Invoke(new EventHandler(this.SetProgressMax));
> > this.SetGotScheduleToTrue();
> > this.HideProgressBar();
> > this.btnDownloadSchedule.Enabled = true;
> > }
> > catch(Exception ex)
> > {
> > MessageBoxes.ErrorMessageBox(ex.ToString(), "Here 2");
> > /*if(MessageBoxes.QuestionMessageBox("There ws a problem fulfilling
> your
> > last request, would you like to try again?", "Communication Failure : "
+
> > ex.ToString()) == DialogResult.Yes)
> > {
> >
> //this.GetSchedule(DateTime.Parse(this.cboYear.SelectedValue.ToString()
> > + "/" + this.cboMonth.SelectedValue.ToString() + "/" +
> > this.cboDay.SelectedValue.ToString()));
> > }*/
> > }
> > }
> >
> > private DateTime GetDate()
> > {
> > return DateTime.Parse(this.cboYear.SelectedValue.ToString() + "/" +
> > this.cboMonth.SelectedValue.ToString() + "/" +
> > this.cboDay.SelectedValue.ToString());
> > }
> >
> > public void UpdateProgressBar(object sender, EventArgs e)
> > {
> > while(!this.bolGotSchedule)
> > {
> > if(this.pbStatus.Value == this.pbStatus.Maximum)
> > {
> > this.pbStatus.Value = this.pbStatus.Minimum;
> > }
> >
> > this.pbStatus.Value += 5;
> > Application.DoEvents();
> > }
> > }
> >
> > public void SetProgressMax(object sender, EventArgs e)
> > {
> > this.pbStatus.Value = this.pbStatus.Maximum;
> > Application.DoEvents();
> > }
> >
> > public void ShowProgressBar()
> > {
> > this.pbStatus.Invoke(new EventHandler(ShowProgressBar));
> > }
> >
> > public void ShowProgressBar(object sender, EventArgs e)
> > {
> > this.pbStatus.Visible = true;
> > }
> >
> > public void HideProgressBar()
> > {
> > this.pbStatus.Invoke(new EventHandler(HideProgressBar));
> > }
> >
> > public void HideProgressBar(object sender, EventArgs e)
> > {
> > this.pbStatus.Visible = false;
> > }
> >
> > public void SetGotScheduleToTrue()
> > {
> > this.Invoke(new EventHandler(SetGotScheduleToTrue));
> > }
> >
> > public void SetGotScheduleToTrue(object sender, EventArgs e)
> > {
> > this.bolGotSchedule = true;
> > }
> >
> > public void SetGotScheduleToFalse()
> > {
> > this.Invoke(new EventHandler(SetGotScheduleToFalse));
> > }
> >
> > Although it has not crashed any devices, the app is still in development
> and
> > has not run that much on real devices. At the moment I think it is a
> glitch
> > with the emulator, but I would appreciate any feedback on the code.
> >
> > Mark
> >
> >
>
>



Re: code crashes emulator by Paul

Paul
Mon Jul 12 11:02:44 CDT 2004

Are you sure that you aren't performing some synchronous network operation
from the user interface thread? If something took a long time to respond,
your UI would be 'dead' until you either got the response that you wanted or
the operation timed-out.

Paul T.

"Mark Irvine" <markpirvine@hotmail.com> wrote in message
news:%23eSJ$F$ZEHA.3512@TK2MSFTNGP12.phx.gbl...
> Alex,
>
> Thanks for the reply. There is no error message. The app just stops
> responding. The only way to get going again is to use the memory
management
> tool in settings or soft reset the emulator.
>
> Mark
>
> "Alex Feinman [MVP]" <public_news@alexfeinman.com> wrote in message
> news:eMWKQn8ZEHA.2016@TK2MSFTNGP09.phx.gbl...
> > Crashes how? Do you get a fault inside the emulator code, emulated OS or
> > your own app?
> >
> > "Mark Irvine" <markpirvine@hotmail.com> wrote in message
> > news:u5efjIqZEHA.2340@TK2MSFTNGP09.phx.gbl...
> > > Hi,
> > >
> > > I am making an async web service call and a progress bar that just
loops
> > > until the call is complete. Before I make the call I set a bool var
to
> > > false I the invoke the progress bar and while this var is false the
bar
> > > will continue to loop. When the call completes this var is set to
true
> > and
> > > the progress bar is stopped and hidden. The probelm is that sometime
it
> > > crashes the emulator, however it has not yet crashed an actual pocket
pc
> > > device. As I am dealing with more than one thread I am using the
Invoke
> > > methods. The key code is included below:
> > >
> > > private void btnDownloadSchedule_Click(object sender, System.EventArgs
> e)
> > > {
> > > this.btnDownloadSchedule.Enabled = false;
> > > this.ShowProgressBar();
> > > this.SetGotScheduleToFalse();
> > >
> > > this.wsSchedule = new
> > > Heat.IntelligentScheduler.Pda.App.wsHeatSchedule.Schedule();
> > > this.wsSchedule.BeginGetSchedule(this.mScheduling.EngineerId,
> > > this.GetDate().ToShortDateString(), wsHeatSchedule.JobPriority.All,
new
> > > AsyncCallback(ScheduleCallback), null);
> > > }
> > >
> > > private void ScheduleCallback(IAsyncResult iarSchedule)
> > > {
> > > try
> > > {
> > > this.wsSchedule.EndGetSchedule(iarSchedule, out this.xnHigh, out
> > > this.xnAM, out this.xnPM);
> > >
> > > this.mScheduling.AddScheduleData(this.xnHigh, JobPriority.All,
> > > this.GetDate());
> > > this.wsSchedule.Abort();
> > >
> > > this.pbStatus.Invoke(new EventHandler(this.SetProgressMax));
> > > this.SetGotScheduleToTrue();
> > > this.HideProgressBar();
> > > this.btnDownloadSchedule.Enabled = true;
> > > }
> > > catch(Exception ex)
> > > {
> > > MessageBoxes.ErrorMessageBox(ex.ToString(), "Here 2");
> > > /*if(MessageBoxes.QuestionMessageBox("There ws a problem
fulfilling
> > your
> > > last request, would you like to try again?", "Communication Failure :
"
> +
> > > ex.ToString()) == DialogResult.Yes)
> > > {
> > >
> > //this.GetSchedule(DateTime.Parse(this.cboYear.SelectedValue.ToString()
> > > + "/" + this.cboMonth.SelectedValue.ToString() + "/" +
> > > this.cboDay.SelectedValue.ToString()));
> > > }*/
> > > }
> > > }
> > >
> > > private DateTime GetDate()
> > > {
> > > return DateTime.Parse(this.cboYear.SelectedValue.ToString() + "/" +
> > > this.cboMonth.SelectedValue.ToString() + "/" +
> > > this.cboDay.SelectedValue.ToString());
> > > }
> > >
> > > public void UpdateProgressBar(object sender, EventArgs e)
> > > {
> > > while(!this.bolGotSchedule)
> > > {
> > > if(this.pbStatus.Value == this.pbStatus.Maximum)
> > > {
> > > this.pbStatus.Value = this.pbStatus.Minimum;
> > > }
> > >
> > > this.pbStatus.Value += 5;
> > > Application.DoEvents();
> > > }
> > > }
> > >
> > > public void SetProgressMax(object sender, EventArgs e)
> > > {
> > > this.pbStatus.Value = this.pbStatus.Maximum;
> > > Application.DoEvents();
> > > }
> > >
> > > public void ShowProgressBar()
> > > {
> > > this.pbStatus.Invoke(new EventHandler(ShowProgressBar));
> > > }
> > >
> > > public void ShowProgressBar(object sender, EventArgs e)
> > > {
> > > this.pbStatus.Visible = true;
> > > }
> > >
> > > public void HideProgressBar()
> > > {
> > > this.pbStatus.Invoke(new EventHandler(HideProgressBar));
> > > }
> > >
> > > public void HideProgressBar(object sender, EventArgs e)
> > > {
> > > this.pbStatus.Visible = false;
> > > }
> > >
> > > public void SetGotScheduleToTrue()
> > > {
> > > this.Invoke(new EventHandler(SetGotScheduleToTrue));
> > > }
> > >
> > > public void SetGotScheduleToTrue(object sender, EventArgs e)
> > > {
> > > this.bolGotSchedule = true;
> > > }
> > >
> > > public void SetGotScheduleToFalse()
> > > {
> > > this.Invoke(new EventHandler(SetGotScheduleToFalse));
> > > }
> > >
> > > Although it has not crashed any devices, the app is still in
development
> > and
> > > has not run that much on real devices. At the moment I think it is a
> > glitch
> > > with the emulator, but I would appreciate any feedback on the code.
> > >
> > > Mark
> > >
> > >
> >
> >
>
>



Re: code crashes emulator by ilyatum

ilyatum
Mon Jul 12 12:42:01 CDT 2004

Are you updating UI from asynchronous WS thread?
You can't do that without using Control.Invoke(). Please see this for more
details:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnnetcomp/h
tml/netcfmultithreadedapp.asp


Best regards,

Ilya

This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
> Reply-To: "Mark Irvine" <markpirvine@hotmail.com>
> From: "Mark Irvine" <markpirvine@hotmail.com>
> References: <u5efjIqZEHA.2340@TK2MSFTNGP09.phx.gbl>
<eMWKQn8ZEHA.2016@TK2MSFTNGP09.phx.gbl>
> Subject: Re: code crashes emulator
> Date: Mon, 12 Jul 2004 10:20:32 +0100
> Lines: 149
> X-Priority: 3
> X-MSMail-Priority: Normal
> X-Newsreader: Microsoft Outlook Express 6.00.2800.1409
> X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1409
> Message-ID: <#eSJ$F$ZEHA.3512@TK2MSFTNGP12.phx.gbl>
> Newsgroups: microsoft.public.dotnet.framework.compactframework
> NNTP-Posting-Host: marki220.gotadsl.co.uk 213.208.117.141
> Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP12.phx.gbl
> Xref: cpmsftngxa06.phx.gbl
microsoft.public.dotnet.framework.compactframework:57111
> X-Tomcat-NG: microsoft.public.dotnet.framework.compactframework
>
> Alex,
>
> Thanks for the reply. There is no error message. The app just stops
> responding. The only way to get going again is to use the memory
management
> tool in settings or soft reset the emulator.
>
> Mark
>
> "Alex Feinman [MVP]" <public_news@alexfeinman.com> wrote in message
> news:eMWKQn8ZEHA.2016@TK2MSFTNGP09.phx.gbl...
> > Crashes how? Do you get a fault inside the emulator code, emulated OS or
> > your own app?
> >
> > "Mark Irvine" <markpirvine@hotmail.com> wrote in message
> > news:u5efjIqZEHA.2340@TK2MSFTNGP09.phx.gbl...
> > > Hi,
> > >
> > > I am making an async web service call and a progress bar that just
loops
> > > until the call is complete. Before I make the call I set a bool var
to
> > > false I the invoke the progress bar and while this var is false the
bar
> > > will continue to loop. When the call completes this var is set to
true
> > and
> > > the progress bar is stopped and hidden. The probelm is that sometime
it
> > > crashes the emulator, however it has not yet crashed an actual pocket
pc
> > > device. As I am dealing with more than one thread I am using the
Invoke
> > > methods. The key code is included below:
> > >
> > > private void btnDownloadSchedule_Click(object sender, System.EventArgs
> e)
> > > {
> > > this.btnDownloadSchedule.Enabled = false;
> > > this.ShowProgressBar();
> > > this.SetGotScheduleToFalse();
> > >
> > > this.wsSchedule = new
> > > Heat.IntelligentScheduler.Pda.App.wsHeatSchedule.Schedule();
> > > this.wsSchedule.BeginGetSchedule(this.mScheduling.EngineerId,
> > > this.GetDate().ToShortDateString(), wsHeatSchedule.JobPriority.All,
new
> > > AsyncCallback(ScheduleCallback), null);
> > > }
> > >
> > > private void ScheduleCallback(IAsyncResult iarSchedule)
> > > {
> > > try
> > > {
> > > this.wsSchedule.EndGetSchedule(iarSchedule, out this.xnHigh, out
> > > this.xnAM, out this.xnPM);
> > >
> > > this.mScheduling.AddScheduleData(this.xnHigh, JobPriority.All,
> > > this.GetDate());
> > > this.wsSchedule.Abort();
> > >
> > > this.pbStatus.Invoke(new EventHandler(this.SetProgressMax));
> > > this.SetGotScheduleToTrue();
> > > this.HideProgressBar();
> > > this.btnDownloadSchedule.Enabled = true;
> > > }
> > > catch(Exception ex)
> > > {
> > > MessageBoxes.ErrorMessageBox(ex.ToString(), "Here 2");
> > > /*if(MessageBoxes.QuestionMessageBox("There ws a problem
fulfilling
> > your
> > > last request, would you like to try again?", "Communication Failure :
"
> +
> > > ex.ToString()) == DialogResult.Yes)
> > > {
> > >
> > //this.GetSchedule(DateTime.Parse(this.cboYear.SelectedValue.ToString()
> > > + "/" + this.cboMonth.SelectedValue.ToString() + "/" +
> > > this.cboDay.SelectedValue.ToString()));
> > > }*/
> > > }
> > > }
> > >
> > > private DateTime GetDate()
> > > {
> > > return DateTime.Parse(this.cboYear.SelectedValue.ToString() + "/" +
> > > this.cboMonth.SelectedValue.ToString() + "/" +
> > > this.cboDay.SelectedValue.ToString());
> > > }
> > >
> > > public void UpdateProgressBar(object sender, EventArgs e)
> > > {
> > > while(!this.bolGotSchedule)
> > > {
> > > if(this.pbStatus.Value == this.pbStatus.Maximum)
> > > {
> > > this.pbStatus.Value = this.pbStatus.Minimum;
> > > }
> > >
> > > this.pbStatus.Value += 5;
> > > Application.DoEvents();
> > > }
> > > }
> > >
> > > public void SetProgressMax(object sender, EventArgs e)
> > > {
> > > this.pbStatus.Value = this.pbStatus.Maximum;
> > > Application.DoEvents();
> > > }
> > >
> > > public void ShowProgressBar()
> > > {
> > > this.pbStatus.Invoke(new EventHandler(ShowProgressBar));
> > > }
> > >
> > > public void ShowProgressBar(object sender, EventArgs e)
> > > {
> > > this.pbStatus.Visible = true;
> > > }
> > >
> > > public void HideProgressBar()
> > > {
> > > this.pbStatus.Invoke(new EventHandler(HideProgressBar));
> > > }
> > >
> > > public void HideProgressBar(object sender, EventArgs e)
> > > {
> > > this.pbStatus.Visible = false;
> > > }
> > >
> > > public void SetGotScheduleToTrue()
> > > {
> > > this.Invoke(new EventHandler(SetGotScheduleToTrue));
> > > }
> > >
> > > public void SetGotScheduleToTrue(object sender, EventArgs e)
> > > {
> > > this.bolGotSchedule = true;
> > > }
> > >
> > > public void SetGotScheduleToFalse()
> > > {
> > > this.Invoke(new EventHandler(SetGotScheduleToFalse));
> > > }
> > >
> > > Although it has not crashed any devices, the app is still in
development
> > and
> > > has not run that much on real devices. At the moment I think it is a
> > glitch
> > > with the emulator, but I would appreciate any feedback on the code.
> > >
> > > Mark
> > >
> > >
> >
> >
>
>
>


Re: code crashes emulator by Mark

Mark
Mon Jul 12 12:43:56 CDT 2004

Paul,

I'm start an async call to a webservice, but that should automatically go on
another thread, is that correct?

Mark

"Paul G. Tobey [eMVP]" <ptobey_no_spam@instrument_no_spam.com> wrote in
message news:%23Ln4omCaEHA.2388@TK2MSFTNGP11.phx.gbl...
> Are you sure that you aren't performing some synchronous network operation
> from the user interface thread? If something took a long time to respond,
> your UI would be 'dead' until you either got the response that you wanted
or
> the operation timed-out.
>
> Paul T.
>
> "Mark Irvine" <markpirvine@hotmail.com> wrote in message
> news:%23eSJ$F$ZEHA.3512@TK2MSFTNGP12.phx.gbl...
> > Alex,
> >
> > Thanks for the reply. There is no error message. The app just stops
> > responding. The only way to get going again is to use the memory
> management
> > tool in settings or soft reset the emulator.
> >
> > Mark
> >
> > "Alex Feinman [MVP]" <public_news@alexfeinman.com> wrote in message
> > news:eMWKQn8ZEHA.2016@TK2MSFTNGP09.phx.gbl...
> > > Crashes how? Do you get a fault inside the emulator code, emulated OS
or
> > > your own app?
> > >
> > > "Mark Irvine" <markpirvine@hotmail.com> wrote in message
> > > news:u5efjIqZEHA.2340@TK2MSFTNGP09.phx.gbl...
> > > > Hi,
> > > >
> > > > I am making an async web service call and a progress bar that just
> loops
> > > > until the call is complete. Before I make the call I set a bool var
> to
> > > > false I the invoke the progress bar and while this var is false the
> bar
> > > > will continue to loop. When the call completes this var is set to
> true
> > > and
> > > > the progress bar is stopped and hidden. The probelm is that
sometime
> it
> > > > crashes the emulator, however it has not yet crashed an actual
pocket
> pc
> > > > device. As I am dealing with more than one thread I am using the
> Invoke
> > > > methods. The key code is included below:
> > > >
> > > > private void btnDownloadSchedule_Click(object sender,
System.EventArgs
> > e)
> > > > {
> > > > this.btnDownloadSchedule.Enabled = false;
> > > > this.ShowProgressBar();
> > > > this.SetGotScheduleToFalse();
> > > >
> > > > this.wsSchedule = new
> > > > Heat.IntelligentScheduler.Pda.App.wsHeatSchedule.Schedule();
> > > > this.wsSchedule.BeginGetSchedule(this.mScheduling.EngineerId,
> > > > this.GetDate().ToShortDateString(), wsHeatSchedule.JobPriority.All,
> new
> > > > AsyncCallback(ScheduleCallback), null);
> > > > }
> > > >
> > > > private void ScheduleCallback(IAsyncResult iarSchedule)
> > > > {
> > > > try
> > > > {
> > > > this.wsSchedule.EndGetSchedule(iarSchedule, out this.xnHigh, out
> > > > this.xnAM, out this.xnPM);
> > > >
> > > > this.mScheduling.AddScheduleData(this.xnHigh, JobPriority.All,
> > > > this.GetDate());
> > > > this.wsSchedule.Abort();
> > > >
> > > > this.pbStatus.Invoke(new EventHandler(this.SetProgressMax));
> > > > this.SetGotScheduleToTrue();
> > > > this.HideProgressBar();
> > > > this.btnDownloadSchedule.Enabled = true;
> > > > }
> > > > catch(Exception ex)
> > > > {
> > > > MessageBoxes.ErrorMessageBox(ex.ToString(), "Here 2");
> > > > /*if(MessageBoxes.QuestionMessageBox("There ws a problem
> fulfilling
> > > your
> > > > last request, would you like to try again?", "Communication Failure
:
> "
> > +
> > > > ex.ToString()) == DialogResult.Yes)
> > > > {
> > > >
> > >
//this.GetSchedule(DateTime.Parse(this.cboYear.SelectedValue.ToString()
> > > > + "/" + this.cboMonth.SelectedValue.ToString() + "/" +
> > > > this.cboDay.SelectedValue.ToString()));
> > > > }*/
> > > > }
> > > > }
> > > >
> > > > private DateTime GetDate()
> > > > {
> > > > return DateTime.Parse(this.cboYear.SelectedValue.ToString() + "/"
+
> > > > this.cboMonth.SelectedValue.ToString() + "/" +
> > > > this.cboDay.SelectedValue.ToString());
> > > > }
> > > >
> > > > public void UpdateProgressBar(object sender, EventArgs e)
> > > > {
> > > > while(!this.bolGotSchedule)
> > > > {
> > > > if(this.pbStatus.Value == this.pbStatus.Maximum)
> > > > {
> > > > this.pbStatus.Value = this.pbStatus.Minimum;
> > > > }
> > > >
> > > > this.pbStatus.Value += 5;
> > > > Application.DoEvents();
> > > > }
> > > > }
> > > >
> > > > public void SetProgressMax(object sender, EventArgs e)
> > > > {
> > > > this.pbStatus.Value = this.pbStatus.Maximum;
> > > > Application.DoEvents();
> > > > }
> > > >
> > > > public void ShowProgressBar()
> > > > {
> > > > this.pbStatus.Invoke(new EventHandler(ShowProgressBar));
> > > > }
> > > >
> > > > public void ShowProgressBar(object sender, EventArgs e)
> > > > {
> > > > this.pbStatus.Visible = true;
> > > > }
> > > >
> > > > public void HideProgressBar()
> > > > {
> > > > this.pbStatus.Invoke(new EventHandler(HideProgressBar));
> > > > }
> > > >
> > > > public void HideProgressBar(object sender, EventArgs e)
> > > > {
> > > > this.pbStatus.Visible = false;
> > > > }
> > > >
> > > > public void SetGotScheduleToTrue()
> > > > {
> > > > this.Invoke(new EventHandler(SetGotScheduleToTrue));
> > > > }
> > > >
> > > > public void SetGotScheduleToTrue(object sender, EventArgs e)
> > > > {
> > > > this.bolGotSchedule = true;
> > > > }
> > > >
> > > > public void SetGotScheduleToFalse()
> > > > {
> > > > this.Invoke(new EventHandler(SetGotScheduleToFalse));
> > > > }
> > > >
> > > > Although it has not crashed any devices, the app is still in
> development
> > > and
> > > > has not run that much on real devices. At the moment I think it is
a
> > > glitch
> > > > with the emulator, but I would appreciate any feedback on the code.
> > > >
> > > > Mark
> > > >
> > > >
> > >
> > >
> >
> >
>
>