Hi all,
I've wrote a Webservice which return a Dataset.
I have made an object on a client pc to acces this webservice.
The asynchhroned call to webservice fill correctly my dataset.
But when in my form, I wish to use this Dataset, I get error at runtime.
Datagrid1.datasource = MyObject.MyDataset
Do not provide error on compilation.
With an asynchroned call, does the system create a secondary thread.
The dataset seem not to be part of the principal thread.
So how can I bind then returned datas.
Thanks a lot for your help.
Trebek - 12 Aug 2004 12:09 GMT
It is possible that the callback is not on the Message pump thread. I would
suggest that you check and see by calling InvokeRequired. If so, simply
define a delegate and method that implements this delegate to bind the
datagrid and invoke it from the web service async callback.
EX in C# (Sorry -- never messed with VB):
//Delegate definition
public delegate void DelBindMyGrid(DataSet ds);
//In async callback
DataSet ds = ws.EndMethod(ir);
this.Invoke(new DelBindMyGrid(BindGrid),new object[]{ds});
//Delegate method to bind grid -- called thru invoke to run under msg
pump thread
private void BindGrid(DataSet ds)
{
Datagrid1.datasource = MyObject.MyDataset;
}
HTH,
Alex
> Hi all,
>
[quoted text clipped - 14 lines]
>
> Thanks a lot for your help.