Welcome Guest! To enable all features, please Login or Register.

Notification

Icon
Error

Options
View
Last Go to last post Unread Go to first unread post
#1 Posted : Tuesday, March 8, 2011 5:04:20 AM(UTC)

tpinc  
tpinc

Groups: Registered
Posts: 11


Hi All,

I have a question about the LoadAsync method of the RasterCodecs class. When I attempt to use it, it causes my application to crash if the image does not exist (file not found exception), because it is impossible to trap an exception coming from the internal thread. Using the codecs.ThrowExceptionsOnInvalidImages = False it should not (to my understanding) throw exceptions during image load, however it's still being thrown. I also had the understanding that the event "LoadAsyncCompleted" would fire and have a property on the CodecsLoadAsyncCompletedEventArgs argument indicating the exception.

The questions I suppose are, is this expected behavior? and is there a way to prevent the throwing of the exception if the image does not exist during the LoadAsync?
 

Try the latest version of LEADTOOLS for free for 60 days by downloading the evaluation: https://www.leadtools.com/downloads

Wanna join the discussion? Login to your LEADTOOLS Support accountor Register a new forum account.

#2 Posted : Tuesday, March 8, 2011 12:16:35 PM(UTC)

Danny H  
Guest

Groups: Guests
Posts: 3,022

Was thanked: 2 time(s) in 2 post(s)

I would like to discuss this further in a support ticket.

If you would email support@leadtools.com we will take it from there.
 
#3 Posted : Tuesday, March 8, 2011 12:24:18 PM(UTC)

tpinc  
tpinc

Groups: Registered
Posts: 11


May I clarify who Danny H is? According to his forum profile the profile was created today and does not bear the markings of an official LEADTools forum moderator or employee that I've seen responding to other threads.
 
#4 Posted : Wednesday, March 9, 2011 12:51:05 AM(UTC)

Adam Boulad  
Guest

Groups: Guests
Posts: 3,022

Was thanked: 2 time(s) in 2 post(s)

Yes. Danny is a LEAD Support employee. His profile was not updated yet. But it should be updated soon. Please follow Danny's instructions and send an email to support@leadtools.com.

Thank you for your cooperation.
 
#5 Posted : Wednesday, March 9, 2011 3:11:12 AM(UTC)

tpinc  
tpinc

Groups: Registered
Posts: 11


Email has been sent. Thank you for your time, and thank you to the rest of the support staff ahead of time!
 
#6 Posted : Wednesday, March 9, 2011 1:47:07 PM(UTC)

Danny H  
Guest

Groups: Guests
Posts: 3,022

Was thanked: 2 time(s) in 2 post(s)

The ThrowExceptionOnInvalidImages property is refering to our internal exceptions. It
is understood that the file has already been verified as being in existance.

There are two ways to handle this. Both can be used if the file is local. The second can
be used even if the file is a URL.

1:
if ( File.Exists( "nameoffile" ) == true )
{
image = LoadAsync( "nameoffile", null )\;
}

2:

if ( IsUrlValid( "nameoffile" ) == true )
{
image = LoadAsync( "nameoffile", null )\;
}

public static bool IsUrlValid(string URL)
{
try
{
HttpWebRequest webRequest = (HttpWebRequest)WebRequest.Create(URL)\;
using (HttpWebResponse webResponse=(HttpWebResponse)
webRequest.GetResponse())
{
if (webResponse.StatusCode == HttpStatusCode.OK)
return true\;
}
}
catch
{
}

return false\;
}


Like I said either of these solutions will work for you and prevent the file does not exist
exception from ever occuring. All of our internal exceptions will be reported in the callback.
 
#7 Posted : Thursday, March 10, 2011 3:53:12 AM(UTC)

tpinc  
tpinc

Groups: Registered
Posts: 11


Thank you for the response. It would have been nice if the LoadAsync method did actually handle for most of the exceptions. Because of the environment I'm in a network timeout can take as many as 11 seconds, hence the need for the async. Instead of using the built in method LoadAsync I'm now using a background worker object and the normal Codecs.Load method.

Again, thank you for your time!
 
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

Powered by YAF.NET | YAF.NET © 2003-2024, Yet Another Forum.NET
This page was generated in 1.996 seconds.