cancel
Showing results for 
Search instead for 
Did you mean: 

Asynchronous call

Former Member
0 Kudos

Hi Reiner,

I have created my delegate and callback function for an Asynchronous windows application. After the BeginXXX function that has been processed,the return parameters at EndXXX is ok, I see the values of my table returned in the debugger. However because my table is a datamember from the Proxy field i dropped and configured earlier and bound to a datagrid, the values are not binding to the datagrid. In synchronous mode, it works, and in this mode it does not bind. I am not really a VS expert, is there another command I should be using to refresh the contents of my table after the async call?

cheers

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi,

If you use the BeginXXX and EndXXX methods pair generated by the Wizard to make the asynchronous call, instead of creating your own delegates, the connector runtime will refresh the bound controls for you automatically.

You can ask wizard to generate methods for asynchronous calls by setting the property CreateAsyncs of your .sapwsdl file to "true".

Regards,

Guangwei

Former Member
0 Kudos

Hi Li, how are you? urr my BeginXXX and EndXXX were generated...what I meant was the the async variables were created in order to instantiate the BeginXXX and EndXXX like

private myAsyncState as object

private mycallback as System.AsyncCallback

private asyncresult as IAsyncresult

i just bound the DataSource to my proxyfield which happens to be the return table. When I debug there are values, however it is not refreshing the control. Is this a bug?

Cheers

Former Member
0 Kudos

Hi Li,

I solved the problem already. You might be interested to look into this. In the FAQ I was asked to bind my data to the data grid with either one of two ways;

(1) Populate the DataSource property of the DataGrid with the <proxy> and DataMember property with <TableProxyField>; or

(2) Populate the DataSource as <Proxy>.<TableProxyField>

I found with Asynchronous that I can't do method (1), which has been giving me that problem of the DataGrid not being refreshed after the EndXXX returns my table value. Is this a limitation per se? or was it always meant to be?

It works fine with method (2)

tschuss

Message was edited by: Khoon Cheng Ho

reiner_hille-doering
Active Contributor
0 Kudos

Windows Forms databinding in conjunction with asyncronous calls is a teribly complicated thing, even if you normally wont recognise it.

This is caused by the fact that Windows forms controls are not thread-safe. You are not allowed to do any modification on a control outside the thread that created the control. This statement is also valid for datanbinding. As EndInvoke is called on a different thread, it MUST normally NOT update any control.

We have a trick in NCo that automatically turns off Databdinding in BeginInvoke (by setting the table's SupportChangeNotification to false) and later in EndInvoke calls SAPClient.RefreshBoundTables -> SAPStructure.RefreshBindings - which internally uses some special API do update the databinding even from the different thread.

And you are righ - this works only for databindings where "DataMember" is empty. For the other case you would need some additional manual coding.