←Select platform

GetInformationAsyncCompleted Event

Summary
Indicates that an asynchronous get information operation has been completed.
Syntax
C#
VB
C++
Java
publiceventEventHandler<CodecsGetInformationAsyncCompletedEventArgs> GetInformationAsyncCompleted
PublicEventGetInformationAsyncCompletedAsEventHandler(Of CodecsGetInformationAsyncCompletedEventArgs)
synchronizedpublicvoidaddGetInformationAsyncCompletedListener(CodecsGetInformationAsyncCompletedListener listener)synchronizedpublicvoidremoveGetInformationAsyncCompletedListener(CodecsGetInformationAsyncCompletedListener listener)
public:eventEventHandler^ GetInformationAsyncCompleted
Event Data

The event handler receives an argument of typeCodecsGetInformationAsyncCompletedEventArgscontaining data related to this event. The followingCodecsGetInformationAsyncCompletedEventArgsproperties provide information specific to this event.

Property Description
Cancelled(Inherited fromSystem.ComponentModel.AsyncCompletedEventArgs) Gets a value indicating whether an asynchronous operation has been canceled.
Error(Inherited fromSystem.ComponentModel.AsyncCompletedEventArgs) Gets a value indicating which error occurred during an asynchronous operation.
FileName(Inherited fromLeadtools.Codecs.CodecsAsyncCompletedEventArgs) Gets the file name this asynchronous operation is using.
Info Gets theCodecsImageInfoclass instance that contains the information about the image file.
Stream(Inherited fromLeadtools.Codecs.CodecsAsyncCompletedEventArgs) Gets the stream this asynchronous operation is using.
Uri(Inherited fromLeadtools.Codecs.CodecsAsyncCompletedEventArgs) Gets the URI this asynchronous operation is using.
UserState(Inherited fromSystem.ComponentModel.AsyncCompletedEventArgs) Gets the unique identifier for the asynchronous task.
Remarks

NOTE: This topic is part ofRasterCodecsAsync support using the .NETSystem.ComponentMode.AsyncOperationmodel. For .NETasync/awaitsupport this type/member is not used. Instead, refer toRasterCodecs Async Operations.

TheRasterCodecsclass supports getting information on image files asynchronously using theGetInformationAsyncmethods. When calling any of these methods, the caller thread will not be blocked and the method will return instantly with an instanceCodecsImageInfothat is in a loading status (CodecsImageInfo.IsLoadingset totrue). You should not use the other properties of this object while the object is in loading status.

When theRasterCodecsobject finishes getting the information about the file, the various properties of theCodecsImageInfowill be populated with the image file information and theCodecsImageInfo.IsLoadingproperty will be set tofalse.

It is recommended that you do not poll for theCodecsImageInfo.IsLoadingproperty to determine whether the image information has been collected. Instead, subscribe to theGetInformationAsyncCompletedevent to get notification on when theGetInformationAsyncoperation is completed and whether any errors occurred.

TheGetInformationAsyncCompletedevent data will also contain the same object returned fromGetInformationAsyncso you do not have to keep the original object in your application.

TheGetInformationAsyncCompletedevent uses a data argument object of typeCodecsGetInformationAsyncCompletedEventArgs. This class contains the following properties:

Property Description
CodecsGetInformationAsyncCompletedEventArgs.Uri,CodecsGetInformationAsyncCompletedEventArgs.StreamandCodecsGetInformationAsyncCompletedEventArgs.FileName

Contains the URI, stream or file name passed to the method that initialized this asynchronous operation.

Only one of these properties can be a valid value (not anullreference) at any time The property that contains a valid reference depends on what version ofGetInformationAsyncmethod has been called.

For example, ifGetInformationAsync(Uri uri, bool totalPages, int pageNumberobject, object userState)is being called, theUriwill contain the same URI passed to the method whileStreamandFileNamewill both benull. IfGetInformationAsync(string fileName, bool totalPages, int pageNumberobject, object userState)is being called, theFileNamewill contain the same file name string value passed to the method whileUriandStreamwill both benulland so on.

CodecsGetInformationAsyncCompletedEventArgs.Info

Contains theCodecsImageInfoclass instance that contains the information about the image file. This instance is the same object returned from theGetInformationAsyncmethod. While the asynchronous operation is running, the value of theCodecsImageInfo.IsLoadingwill betrueindicating that the object is being populated with the information and should not be used. When the asynchronous operation completes, theGetInformationAsyncCompleted事件将火和Infowill contain the final and ready to use object. If an error occurs, this property will be set tonulland the object is disposed internally by the toolkit.

CodecsGetInformationAsyncCompletedEventArgs.Error

Contains any errors that might have occurred during the asynchronous operation. You must check this value when theGetInformationAsyncCompletedevent fires and make sure it does not contain a validExceptionobject.

CodecsGetInformationAsyncCompletedEventArgs.Cancelled

Contains a value indicating whether an asynchronous operation has been canceled. For example, by callingCancelAsyncwhen usingRasterCodecs.GetInformationAsyncwith a URL.

Example
C#
usingLeadtools;usingLeadtools.Codecs;usingLeadtools.ImageProcessing;usingLeadtools.ImageProcessing.Color;usingLeadtools.Svg;publicvoidGetInformationAsyncCompletedExample(){stringsrcFileName = Path.Combine(LEAD_VARS.ImagesDir,"Image1.cmp");Uri uri =newUri(srcFileName);RasterCodecs编解码器=newRasterCodecs();// Now get information about the file asynchronouslycodecs.GetInformationAsyncCompleted +=newEventHandler(GetInformationAsyncCompletedExample_GetInformationAsyncCompleted);objectimageInfoObject = codecs.GetInformationAsync(uri,true, 1,null);// Notice that the returned imageInfoObject is a CodecsImageInfo with IsLoading set to true at this point// The IsLoading will be false (and hence, the object will be usable) when the GetInformationAsyncCompleted// fires.}privatevoidGetInformationAsyncCompletedExample_GetInformationAsyncCompleted(objectsender, CodecsGetInformationAsyncCompletedEventArgs e){if(e.Cancelled){Console.WriteLine("User canceled");}elseif(e.Error !=null){Console.WriteLine("Error: "+ e.Error.Message);}else{// Get the image infoCodecsImageInfo info = e.Info;Console.WriteLine("Image info obtainted asynchronously:\n{0}", info.ToString());info.Dispose();}// Unsubscribe to the event and dispose the RasterCodecs objectRasterCodecs编解码器=senderasRasterCodecs;codecs.GetInformationAsyncCompleted -=newEventHandler(GetInformationAsyncCompletedExample_GetInformationAsyncCompleted);codecs.Dispose();}staticclassLEAD_VARS{publicconststringImagesDir =@"C:\LEADTOOLS21\Resources\Images";}
Requirements

Target Platforms

Leadtools.Codecs Assembly
188金宝搏的网址客服|Support|Contact Us|Intellectual Property Notices
© 1991-2021LEAD Technologies, Inc.All Rights Reserved.