publiceventEventHandler<CodecsGetInformationAsyncCompletedEventArgs> GetInformationAsyncCompleted
PublicEventGetInformationAsyncCompletedAsEventHandler(Of CodecsGetInformationAsyncCompletedEventArgs)
synchronizedpublicvoidaddGetInformationAsyncCompletedListener(CodecsGetInformationAsyncCompletedListener listener)
synchronizedpublicvoidremoveGetInformationAsyncCompletedListener(CodecsGetInformationAsyncCompletedListener listener)
public:
eventEventHandler
^ GetInformationAsyncCompleted
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. |
NOTE: This topic is part ofRasterCodecs
Async support using the .NETSystem.ComponentMode.AsyncOperation
model. For .NETasync/await
support 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. |
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 asynchronously
codecs.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 info
CodecsImageInfo info = e.Info;
Console.WriteLine("Image info obtainted asynchronously:\n{0}", info.ToString());
info.Dispose();
}
// Unsubscribe to the event and dispose the RasterCodecs object
RasterCodecs编解码器=senderasRasterCodecs;
codecs.GetInformationAsyncCompleted -=newEventHandler
(GetInformationAsyncCompletedExample_GetInformationAsyncCompleted); codecs.Dispose();
}
staticclassLEAD_VARS
{
publicconststringImagesDir =@"C:\LEADTOOLS21\Resources\Images";
}
Help Collections
Raster.NET|C API|C++ Class Library|HTML5 JavaScript
Document.NET|C API|C++ Class Library|HTML5 JavaScript
Medical.NET|C API|C++ Class Library|HTML5 JavaScript
Medical Web Viewer.NET
188宝金博怎么下载
Media Foundation.NET|C API|Transforms
Supported Platforms
.NET, Java, Android, and iOS/macOS Assemblies
Imaging, Medical, and Document
C API/C++ Class Libraries
Imaging, Medical, and Document
HTML5 JavaScript Libraries
Your email has been sent to support! Someone should be in touch! If your matter is urgent please come back into chat.
闲谈,聊天Hours:
Monday - Friday, 8:30am to 6pm ET
Thank you for your feedback!
Please fill out the form again to start a new chat.
All agents are currently offline.
闲谈,聊天Hours:
Monday - Friday
8:30AM - 6PM EST
To contact us please fill out this form and we will contact you via email.