Link to home
Start Free TrialLog in
Avatar of nzfire
nzfire

asked on

Run a process while a connection to a web service is being attempted

Hi All,

I would like to display to the user that a connection to a web service is being attempted and display it, otherwise it can appear that the app is hung.

Using an example (theory only)

Dim svc as myservice.service
dim s as string = svc.mymethod("blah")

While the app is waiting for the return from the webservice, I would like to display something....like an animated gif. How could I do this?

Thanks
Avatar of YZlat
YZlat
Flag of United States of America image

use two separate threads
one for web service and one for process
Avatar of Kinger247
Kinger247

You can run the service with a callback, so after you call the webservice tou can run your gif or any other code.
The callback procedure will run to inform you the service has completed.

I've been trying to find some code on the web as an example.
Heres one I did find: http://www.dotnetjohn.com/articles.aspx?articleid=91

The question here lies in when, and what you are really doing.

Typically, you add a web-reference to the web-service you wish to use in your project.

You define an instance and then call it's methods.

The question of "connection" is really one of what connection you are talking about.

In your web-service, are you requiring an authentication to the web-service itself, and then another call (that possibly contains state-date about the connection) to the exposed functions that "do the work"?

If not, this connection to the web-service is nearly transparent and the real connection you are "waiting on" is from the web-service to whatever resource it is touching (like a database).

Really in either case, a couple possible solutions are :

Wrap your call to the web-service methods inside a separate thread and while that thread is executing display a waiting message.

Another possible method :

Create a form that has the animation on it, give it no border or control box and size it to the exact size of the .animation.

When you are about to execute a call to the web-service (say svc.getdata("select * from mytable")), you create an instance of this form FIRST and display it and then make your call to the web-service, when the call gets its "stuff" from the web-service you destroy the instance of the form you just created.

I.E :

private sub get_webData()

dim tmp_Waitform as new frm_waiting
dim svc as myservice.service

tmp_waitform.show

try
    MyReturnData = svc.getdata("select * from mytable")
catch ex as exception
    ' error handling here
finally
   tmp_waitform.dispose
end try
 
end sub





ASKER CERTIFIED SOLUTION
Avatar of Kinger247
Kinger247

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial