xamarin.android - Async web service call in custom list adapter -


i have problem when calling web service asynchronously in monodroid. call seems work correctly, application crashes everytime when process response. program behaves differently when run in emulator , when run on phone (samsung galaxy s w 2.2.1 froyo.xwjs8). thinking of creting threads myself, don't know if solves problem. same code works fine when used in windows phone 7 application.

the code async method call (note: in reality showmessage calls write android.util.log.debug)

private void callws(string _input) {      messagebox.getinstance().showmessage("search async started, input: " + _input);       m_waitingrequest = new requeststatus() { waiting = true, newestinput = _input, originalinput = _input };      connectormobile.userinformation ui = new connectormobile.userinformation()          { username = m_appsettings.getvalue<string>(appsettings.ws_username_name), password = m_appsettings.getvalue<string>(appsettings.ws_password_name) };      messagebox.getinstance().showmessage("username: " + ui.username + " password: " + ui.password);      m_client.searchasync(ui, _input);      messagebox.getinstance().showmessage("after search async call, input: " + _input); } 

search async result function starts with:

void m_client_searchcompleted(object sender, connectormobile.searchcompletedeventargs e) {              messagebox.getinstance().showmessage("search async completed");             searchcache.cacheelement element = new searchcache.cacheelement();             element.searchcriteria = m_waitingrequest.originalinput;             element.partialresponse = e.result.partialresponse;              if (e.result.companynameinfoarray == null)                 element.rows = new list<connectormobile.companynameinfo>();             else                 element.rows = e.result.companynameinfoarray.tolist();             messagebox.getinstance().showmessage("search async returned, partial response: " + e.result.partialresponse                 + " row count: " + element.rows.count + " return value: " + e.result.returnvalue.errordescriptionfi); } 

this program behaves differently. in emulator code never reaches first line of searchcompleted. in phone searchcompleted function seems goes through (at least debug lines in trace), after user interface freezes. (and after minute says process not responding)

you trying modify ui background thread instead of ui thread. use runonuithread () ui logic on correct thread:

http://mono-android.net/documentation/guides/writing_responsive_applications


Comments

Popular posts from this blog

php - What is the difference between $_SERVER['PATH_INFO'] and $_SERVER['ORIG_PATH_INFO']? -

fortran - Function return type mismatch -

queue - mq_receive: message too long -