473,378 Members | 1,493 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

End function if it Takes too long

jr

I have an application the makes a call to a webservice to retrieve some
additional info for my app. The information I get back is
non-essential, so I do NOT want my entire app hanging to wait for this
repsonse if it takes more than, say, 2 seconds to a response from the
webserver.

Basically, how would I immediately end a function that is taking too
long to respond?
--

Jun 27 '08 #1
8 2545
Humm... Have you tried the Timeout property before posting ???

Else elaborate a bit if you have a particular problem (what kind of service
(SOAP ?), do you call it synchronously or not ?)

--
Patrice
"jr" <jr*************@escortinc.coma écrit dans le message de groupe de
discussion : ev**************@TK2MSFTNGP02.phx.gbl...
>
I have an application the makes a call to a webservice to retrieve some
additional info for my app. The information I get back is
non-essential, so I do NOT want my entire app hanging to wait for this
repsonse if it takes more than, say, 2 seconds to a response from the
webserver.

Basically, how would I immediately end a function that is taking too
long to respond?
--
Jun 27 '08 #2
jr
Actually, I'm really only interested in skipping/continuing on with my
application in the event that particular function takes more than a
specified amout of time to repsond.
My original thought was to set up a timer and that would call the sub
every 2 seconds, the first time through the sub, I set a boolean, if
the timer event fires againg and that boolean is set, it took too long
to execute so end the sub. This just seems wrong, and I can already
invision a couple of problems I might have implementing this strategy.
Thanks-
Patrice wrote:
Humm... Have you tried the Timeout property before posting ???

Else elaborate a bit if you have a particular problem (what kind of
service (SOAP ?), do you call it synchronously or not ?)


--

Jun 27 '08 #3
jr,

You should use threading and a timer which set to off if you use the result
of the thread.

Cor

"jr" <jr*************@escortinc.comschreef in bericht
news:OZ******************@TK2MSFTNGP06.phx.gbl...
Actually, I'm really only interested in skipping/continuing on with my
application in the event that particular function takes more than a
specified amout of time to repsond.
My original thought was to set up a timer and that would call the sub
every 2 seconds, the first time through the sub, I set a boolean, if
the timer event fires againg and that boolean is set, it took too long
to execute so end the sub. This just seems wrong, and I can already
invision a couple of problems I might have implementing this strategy.
Thanks-
Patrice wrote:
>Humm... Have you tried the Timeout property before posting ???

Else elaborate a bit if you have a particular problem (what kind of
service (SOAP ?), do you call it synchronously or not ?)

--
Jun 27 '08 #4
"jr" <jr*************@escortinc.comwrote in message
news:ev**************@TK2MSFTNGP02.phx.gbl...
>
I have an application the makes a call to a webservice to retrieve some
additional info for my app. The information I get back is
non-essential, so I do NOT want my entire app hanging to wait for this
repsonse if it takes more than, say, 2 seconds to a response from the
webserver.

Basically, how would I immediately end a function that is taking too
long to respond?
--
Have you thought of using a background worker to make this call?
Jun 27 '08 #5
I'm not sure to fully understand what you are after and in particular what
is the goal of this loop stuff you are talking about. You could :

- have a timeout for the worst case (have you tried ?)

- you could time each call so that you can skip further calls (you are doing
multiple services call for a single request to your web site ?) if the last
one took too long (you can renable those calls if the last call was old
enough in case service responsiveness would be restored now)

- if doing multiple calls you could also make them asynchrounous (this is
built in in the service, you don't have AFAIK to explicitely create a new
thread for this)
"jr" <jr*************@escortinc.coma écrit dans le message de groupe de
discussion : OZ**************@TK2MSFTNGP06.phx.gbl...
Actually, I'm really only interested in skipping/continuing on with my
application in the event that particular function takes more than a
specified amout of time to repsond.
My original thought was to set up a timer and that would call the sub
every 2 seconds, the first time through the sub, I set a boolean, if
the timer event fires againg and that boolean is set, it took too long
to execute so end the sub. This just seems wrong, and I can already
invision a couple of problems I might have implementing this strategy.
Thanks-
Patrice wrote:
>Humm... Have you tried the Timeout property before posting ???

Else elaborate a bit if you have a particular problem (what kind of
service (SOAP ?), do you call it synchronously or not ?)

--
Jun 27 '08 #6
Still a bit in the dark about your need but I do something like that.

I call xoap.something.weather.com every 15 minutes to get the latest
temp by ZIP for where the solar array is installed. If it runs, it
updates the ambient temp field. If it fails, so be it. I will try
again later. There seems to be a default timeout in he code. I am not
setting one but it will fail once or twice per week.

I do it in a different thread and the main program marches on. If the
temp eventually changes, the main thread will update the label field.
Else, it keeps using the old value until a new one comes along.

Sorry if this is no help. Just from personal experience.

Mike

On Fri, 16 May 2008 08:47:10 -0700, in
microsoft.public.dotnet.languages.vb "jr"
<jr*************@escortinc.comwrote:
>
I have an application the makes a call to a webservice to retrieve some
additional info for my app. The information I get back is
non-essential, so I do NOT want my entire app hanging to wait for this
repsonse if it takes more than, say, 2 seconds to a response from the
webserver.

Basically, how would I immediately end a function that is taking too
long to respond?
Jun 27 '08 #7
Patrice,

Some people like to slow down their program by making a thread to let every
in fact synchonous operation to be managed by another process, they think
that the 1000 processors they have in their computers are only busy with
their program.

In this case I gave up to tell this in this case.

Cor

"Patrice" <http://www.chez.com/scribe/schreef in bericht
news:D8**********************************@microsof t.com...
I'm not sure to fully understand what you are after and in particular
what is the goal of this loop stuff you are talking about. You could :

- have a timeout for the worst case (have you tried ?)

- you could time each call so that you can skip further calls (you are
doing multiple services call for a single request to your web site ?) if
the last one took too long (you can renable those calls if the last call
was old enough in case service responsiveness would be restored now)

- if doing multiple calls you could also make them asynchrounous (this is
built in in the service, you don't have AFAIK to explicitely create a new
thread for this)
"jr" <jr*************@escortinc.coma écrit dans le message de groupe de
discussion : OZ**************@TK2MSFTNGP06.phx.gbl...
>Actually, I'm really only interested in skipping/continuing on with my
application in the event that particular function takes more than a
specified amout of time to repsond.
My original thought was to set up a timer and that would call the sub
every 2 seconds, the first time through the sub, I set a boolean, if
the timer event fires againg and that boolean is set, it took too long
to execute so end the sub. This just seems wrong, and I can already
invision a couple of problems I might have implementing this strategy.
Thanks-
Patrice wrote:
>>Humm... Have you tried the Timeout property before posting ???

Else elaborate a bit if you have a particular problem (what kind of
service (SOAP ?), do you call it synchronously or not ?)

--
Jun 27 '08 #8
jr
yes, yes...so correct, many thanks. I didn't see this as an option
before because I was using the Webclient object, which doesn't have the
timeout property accesible (I least I didn't see it)

So I switched to the HttpWebRequest which does and It couldnt be
easier. Although at some point it would be handy to learn how to
accomplish what I originally wanted. Maybe some other time...

Thanks again Patrice!
Patrice wrote:
Have you tried with a time out. IMO you do"nt have anothing special
to do, just set the timeout ot whatever you consider is the max you
can allow and it will timeout if the response doesn't come quick
enought...

Also web services can be called asynchronously out of the box so I
see whay you should handle this yourself...

You could easily test this by using a test service that would take
let 's say 10 s to respond. Then if you set the timoeut ot 8 or 20 s
it will or won't work... I assume that the timout is honored even
when calling the service asynchronously...


--

Jun 27 '08 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
by: JKop | last post by:
Take the following simple function: unsigned long Plus5Percent(unsigned long input) { return ( input + input / 20 ); } Do yous ever consider the possibly more efficent:
3
by: tomailmelookatbottom | last post by:
I am a beginner in C++. I recently downloaded the codes of C++ faq book.Since I don't have the book ,following is two program which is confusing me a lot. program 38_01.cpp ^^^^^^^^^^^^^^^^^...
12
by: strict9 | last post by:
Hello all, I'm writing several queries which need to do various string formating, including changing a phone number from (123) 456-7890. After some problem with data mismatches, I finally got it...
4
by: David Douglass | last post by:
I'm confused about the program below. Based on my reading of the C# spec, I don't think it should compile, but it does when using Beta 1. Could somebody please explain the function selection...
11
by: Russ | last post by:
I have a couple of questions for the number crunchers out there: Does "pow(x,2)" simply square x, or does it first compute logarithms (as would be necessary if the exponent were not an integer)?...
10
by: David Fort | last post by:
Hi, I'm upgrading a VB6 app to VB.net and I'm having a problem with a call to a function provided in a DLL. The function takes the address of a structure which it will fill in with values. I...
74
by: lovecreatesbeauty | last post by:
My small function works, but I have some questions. And I want to listen to you on How it is implemented? 1. The function does not check if parameter x is larger or smaller than parameter y. ...
28
by: Larax | last post by:
Best explanation of my question will be an example, look below at this simple function: function SetEventHandler(element) { // some operations on element element.onclick = function(event) {
10
by: Raj | last post by:
I need a VB function to return array of collections like Private Type Employee empname as string address as string salary as integer deptno as integer End Type dim employees() as Employee
41
by: koolj96825 | last post by:
What is your opinion on function length? Are extra long functions poor style? I have been working on my winprocs and some are getting rather long in length. I could break them up into pieces,...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.