ultra-weird GUI behavior

J

Jeremy

We're all used to weird behaviors with the netcf, right?:p okay well I got
another one. I have honestly tried many of the known tricks to netcf
developers but they don't seem to solve my problem.

(being a good boy, instead of calling a webservice synchronously) I'm
calling a webservice asynchronously. In my callback method I store the
response from the webservice in a new DataSet. All well so far. But then, I
make a call to a previously open form by means of : form.Show() and nothing
happens at all. If however I use another button that only does form.Show()
without any call to any webservice, the previously opened form does show up.

I've tried the usual Application.DoEvents(), this.refresh(),
this.BringToFront() in every possible order. Creating a new instance of the
previously opened form doesn't help either. Ideally, instead of going back
to a previous form I would like to refresh the entire form, but that doesn't
seem to work either (calling this.dispose() or this.InitializeComponent()).
Perhaps it is also worth mentioning that in another part of my application
(i.e. another form) I manage to open a new form from a callback method. Can
someone help me out, please?:)

For what it's worth, here's the callback method:

private void ReserveSeatCompleted (IAsyncResult ar)
{
DataSet tempDS = new DataSet("seatingChart");
BMacsWebService bm = (BMacsWebService)ar.AsyncState;
tempDS = bm.EndReserveSeat(ar);

//Seat reservation successful
if ((tempDS.Tables[0].Columns[0].Caption.ToString()).Equals("status"))
{
GlobalVars.SeatNumberRemote = GlobalVars.SeatNumberLocal;
}

//Seat reservation unsuccessful
else
{
GlobalVars.SeatingChartDs = tempDS;
GlobalVars.seat1.Show();
}
}
 
J

Jeremy

thanks both for your reply. I searched the group for the Invoke method, yet
I'm not too sure yet how to use it. I translated Daniel's code to C#, not
sure how to use it though.

I understand that I should look to do something like :

GlobalVars.seat1.Invoke(new EventHandler(GlobalVars.seat1.Show));

whereas I get : Method 'System.Windows.Forms.Control.Show()' does not match
delegate 'void System.EventHandler(object, System.EventArgs)'

Could you please provide me with more info? thanks a lot!


Daniel Moth said:
You are trying to touch a UI element from a non-UI thread. Use
Control.Invoke:
http://www.danielmoth.com/Blog/2004/10/invoke-cf-and-full-fx.html

Cheers
Daniel
--
http://www.danielmoth.com/Blog/


Jeremy said:
We're all used to weird behaviors with the netcf, right?:p okay well I got
another one. I have honestly tried many of the known tricks to netcf
developers but they don't seem to solve my problem.

(being a good boy, instead of calling a webservice synchronously) I'm
calling a webservice asynchronously. In my callback method I store the
response from the webservice in a new DataSet. All well so far. But then,
I
make a call to a previously open form by means of : form.Show() and
nothing
happens at all. If however I use another button that only does form.Show()
without any call to any webservice, the previously opened form does show
up.

I've tried the usual Application.DoEvents(), this.refresh(),
this.BringToFront() in every possible order. Creating a new instance of
the
previously opened form doesn't help either. Ideally, instead of going back
to a previous form I would like to refresh the entire form, but that
doesn't
seem to work either (calling this.dispose() or
this.InitializeComponent()).
Perhaps it is also worth mentioning that in another part of my application
(i.e. another form) I manage to open a new form from a callback method.
Can
someone help me out, please?:)

For what it's worth, here's the callback method:

private void ReserveSeatCompleted (IAsyncResult ar)
{
DataSet tempDS = new DataSet("seatingChart");
BMacsWebService bm = (BMacsWebService)ar.AsyncState;
tempDS = bm.EndReserveSeat(ar);

//Seat reservation successful
if ((tempDS.Tables[0].Columns[0].Caption.ToString()).Equals("status"))
{
GlobalVars.SeatNumberRemote = GlobalVars.SeatNumberLocal;
}

//Seat reservation unsuccessful
else
{
GlobalVars.SeatingChartDs = tempDS;
GlobalVars.seat1.Show();
}
}
 
D

Daniel Moth

Try something like:

GlobalVars.seat1.Invoke(new EventHandler(MyShow));

private void MyShow(object s, EventArgs e){
GlobalVars.seat1.Show
}

Cheers
Daniel
--
http://www.danielmoth.com/Blog/


Jeremy said:
thanks both for your reply. I searched the group for the Invoke method,
yet
I'm not too sure yet how to use it. I translated Daniel's code to C#, not
sure how to use it though.

I understand that I should look to do something like :

GlobalVars.seat1.Invoke(new EventHandler(GlobalVars.seat1.Show));

whereas I get : Method 'System.Windows.Forms.Control.Show()' does not
match
delegate 'void System.EventHandler(object, System.EventArgs)'

Could you please provide me with more info? thanks a lot!


Daniel Moth said:
You are trying to touch a UI element from a non-UI thread. Use
Control.Invoke:
http://www.danielmoth.com/Blog/2004/10/invoke-cf-and-full-fx.html

Cheers
Daniel
--
http://www.danielmoth.com/Blog/


Jeremy said:
We're all used to weird behaviors with the netcf, right?:p okay well I got
another one. I have honestly tried many of the known tricks to netcf
developers but they don't seem to solve my problem.

(being a good boy, instead of calling a webservice synchronously) I'm
calling a webservice asynchronously. In my callback method I store the
response from the webservice in a new DataSet. All well so far. But then,
I
make a call to a previously open form by means of : form.Show() and
nothing
happens at all. If however I use another button that only does form.Show()
without any call to any webservice, the previously opened form does
show
up.

I've tried the usual Application.DoEvents(), this.refresh(),
this.BringToFront() in every possible order. Creating a new instance of
the
previously opened form doesn't help either. Ideally, instead of going back
to a previous form I would like to refresh the entire form, but that
doesn't
seem to work either (calling this.dispose() or
this.InitializeComponent()).
Perhaps it is also worth mentioning that in another part of my application
(i.e. another form) I manage to open a new form from a callback method.
Can
someone help me out, please?:)

For what it's worth, here's the callback method:

private void ReserveSeatCompleted (IAsyncResult ar)
{
DataSet tempDS = new DataSet("seatingChart");
BMacsWebService bm = (BMacsWebService)ar.AsyncState;
tempDS = bm.EndReserveSeat(ar);

//Seat reservation successful
if ((tempDS.Tables[0].Columns[0].Caption.ToString()).Equals("status"))
{
GlobalVars.SeatNumberRemote = GlobalVars.SeatNumberLocal;
}

//Seat reservation unsuccessful
else
{
GlobalVars.SeatingChartDs = tempDS;
GlobalVars.seat1.Show();
}
}
 
J

Jeremy

he's not very happy.. when debugging he stops at the line
GlobalVars.seat1.Invoke(new EventHandler(MyShow));
i.e. : he doesn't go in the actualy MyShow() method. No error or anything...
any clues?:)

Daniel Moth said:
Try something like:

GlobalVars.seat1.Invoke(new EventHandler(MyShow));

private void MyShow(object s, EventArgs e){
GlobalVars.seat1.Show
}

Cheers
Daniel
--
http://www.danielmoth.com/Blog/


Jeremy said:
thanks both for your reply. I searched the group for the Invoke method,
yet
I'm not too sure yet how to use it. I translated Daniel's code to C#, not
sure how to use it though.

I understand that I should look to do something like :

GlobalVars.seat1.Invoke(new EventHandler(GlobalVars.seat1.Show));

whereas I get : Method 'System.Windows.Forms.Control.Show()' does not
match
delegate 'void System.EventHandler(object, System.EventArgs)'

Could you please provide me with more info? thanks a lot!


Daniel Moth said:
You are trying to touch a UI element from a non-UI thread. Use
Control.Invoke:
http://www.danielmoth.com/Blog/2004/10/invoke-cf-and-full-fx.html

Cheers
Daniel
--
http://www.danielmoth.com/Blog/


We're all used to weird behaviors with the netcf, right?:p okay well
I
got
another one. I have honestly tried many of the known tricks to netcf
developers but they don't seem to solve my problem.

(being a good boy, instead of calling a webservice synchronously) I'm
calling a webservice asynchronously. In my callback method I store the
response from the webservice in a new DataSet. All well so far. But then,
I
make a call to a previously open form by means of : form.Show() and
nothing
happens at all. If however I use another button that only does form.Show()
without any call to any webservice, the previously opened form does
show
up.

I've tried the usual Application.DoEvents(), this.refresh(),
this.BringToFront() in every possible order. Creating a new instance of
the
previously opened form doesn't help either. Ideally, instead of going back
to a previous form I would like to refresh the entire form, but that
doesn't
seem to work either (calling this.dispose() or
this.InitializeComponent()).
Perhaps it is also worth mentioning that in another part of my application
(i.e. another form) I manage to open a new form from a callback method.
Can
someone help me out, please?:)

For what it's worth, here's the callback method:

private void ReserveSeatCompleted (IAsyncResult ar)
{
DataSet tempDS = new DataSet("seatingChart");
BMacsWebService bm = (BMacsWebService)ar.AsyncState;
tempDS = bm.EndReserveSeat(ar);

//Seat reservation successful
if ((tempDS.Tables[0].Columns[0].Caption.ToString()).Equals("status"))
{
GlobalVars.SeatNumberRemote = GlobalVars.SeatNumberLocal;
}

//Seat reservation unsuccessful
else
{
GlobalVars.SeatingChartDs = tempDS;
GlobalVars.seat1.Show();
}
}
 
J

Jeremy

Got it!:)

Problem? mmm.. I'm ashamed... CF SP3 was missing:p both on my PPC and on the
emu.. oops:) After reading Katie's post on:
http://groups-beta.google.com/group...be24ff9a723?q=invoke&rnum=13#49b1abe24ff9a723 I
thought I should double-check that my PPC had SP3 installed. After
installing it, it was working smoothly, with the Control.Invoke thingie:)
when that was done... well, "all" that was left to do was install SP3 on the
emu, which I just did. It works:) yay! I hope this will proof to be of help
to someone else as well!

Last query though: if I just wish to refresh the same form, i.e. refresh all
the controls etc..., what's the best method to use?

thanks a bunch!:) (no seriously!)
 
Top