Leadtools.Codecs名前空間 > RasterCodecsクラス :GetInformationAsyncCompletedイベント |
public event EventHandler<CodecsGetInformationAsyncCompletedEventArgs> GetInformationAsyncCompleted
'Declaration
Public Event GetInformationAsyncCompleted As EventHandler(Of CodecsGetInformationAsyncCompletedEventArgs)
'Usage
Dim instance As RasterCodecs Dim handler As EventHandler(Of CodecsGetInformationAsyncCompletedEventArgs) AddHandler instance.GetInformationAsyncCompleted, handler
public event EventHandler<CodecsGetInformationAsyncCompletedEventArgs> GetInformationAsyncCompleted
synchronized public void addGetInformationAsyncCompletedListener(CodecsGetInformationAsyncCompletedListener listener) synchronized public void removeGetInformationAsyncCompletedListener(CodecsGetInformationAsyncCompletedListener listener)
add_GetInformationAsyncCompleted(function(sender, e)) remove_GetInformationAsyncCompleted(function(sender, e))
public: event EventHandler<CodecsGetInformationAsyncCompletedEventArgs^>^ GetInformationAsyncCompleted
イベントハンドラは、このイベントに関連するデータを格納するタイプCodecsGetInformationAsyncCompletedEventArgsの引数を受け取ります。以下のCodecsGetInformationAsyncCompletedEventArgsプロパティは、このイベントに特有の情報を提供します。
プロパティ | 説明 |
---|---|
Cancelled (Inherited from System.ComponentModel.AsyncCompletedEventArgs) | 非同期動作がキャンセルされたかどうか示している値を取得します。 |
Error (Inherited from System.ComponentModel.AsyncCompletedEventArgs) | どのエラーが非同期動作の間、発生したかについて示している値を取得します。 |
FileName (Inherited from Leadtools.Codecs.CodecsAsyncCompletedEventArgs) | この非同期動作が使用しているファイル名を取得します。 ![]() ![]() |
Info | 画像ファイルに関する情報を格納するCodecsImageInfoクラスインスタンスを取得します。 ![]() ![]() ![]() ![]() |
Stream (Inherited from Leadtools.Codecs.CodecsAsyncCompletedEventArgs) | この非同期動作が使っているストリームを取得します。 ![]() ![]() |
Uri (Inherited from Leadtools.Codecs.CodecsAsyncCompletedEventArgs) | この非同期動作が使っているURIを取得します。 ![]() ![]() |
UserState (Inherited from System.ComponentModel.AsyncCompletedEventArgs) | 非同期タスクの固有識別子を取得します。 |
RasterCodecsクラスは、GetInformationAsyncメソッドを使って画像ファイルに関する情報を非同期に取得するようサポートします。これらのいずれかのメソッドを呼び出すと、コーラースレッドはブロックされ、ロード状態にあるインスタンスCodecsImageInfoでただちに返されます(CodecsImageInfo.IsLoadingをtrueに設定)。オブジェクトがロード状態にある間は、このオブジェクトのその他のプロパティは使用してはなりません。
RasterCodecsオブジェクトでファイルに関する情報の取得が終わると、CodecsImageInfoの様々なプロパティには画像ファイル情報が入力され、CodecsImageInfo.IsLoadingプロパティはfalseに設定されます。
画像情報の収集が完了したかどうかを判断するためにCodecsImageInfo.IsLoadingプロパティをポーリングすることは推奨されません。そうではなく、GetInformationAsync操作がいつ完了するのか、エラーが発生したかどうかに関する情報を得るにはGetInformationAsyncCompletedイベントにサブスクライブします。
GetInformationAsyncCompletedイベントデータにはGetInformationAsyncから返されたものと同じオブジェクトも含まれます。このためアプリケーション内にオリジナルのオブジェクトを保持しておく必要はありません。
GetInformationAsyncCompletedイベントは、型CodecsGetInformationAsyncCompletedEventArgsのデータ引数オブジェクトを使います。このクラスは、以下のプロパティを格納します:
プロパティ | 説明 |
---|---|
CodecsGetInformationAsyncCompletedEventArgs.Uri、CodecsGetInformationAsyncCompletedEventArgs.StreamとCodecsGetInformationAsyncCompletedEventArgs.FileName |
この非同期動作を初期化したメソッドに渡されるURI、ストリームまたはファイル名を格納します。 常に、これらのプロパティのいずれか1つのみが有効な値(null参照ではない値)になります。どのプロパティに有効な参照が含まれるかは、どのバージョンのGetInformationAsyncメソッドが呼び出されたかによって決まります。 たとえばGetInformationAsync(ウーリuri、bool totalPages、int pageNumberobject、オブジェクトuserState)が呼び出されている場合、Uriにはメソッドに渡されるものと同じURIが含まれ、StreamとFileNameはどちらもNULLになります。GetInformationAsync(string fileName、bool totalPages、int pageNumberobject、オブジェクトuserState)が呼び出されている場合、FileNameにはメソッドに渡されるものと同じファイル名の文字列値が含まれ、ウーリとStreamはどちらもNULLになる、等です。 |
CodecsGetInformationAsyncCompletedEventArgs.Info |
画像ファイルに関する情報を格納するCodecsImageInfoクラスインスタンスを格納します。このインスタンスは、GetInformationAsyncメソッドから返される同じオブジェクトです。非同期動作が実行する間、CodecsImageInfo.IsLoadingの値はオブジェクトが情報で値を入力されていて、使われるべきでないことをtrue示しているでしょう。操作が完了する非同期、イベントが発生するGetInformationAsyncCompletedと情報がいつ最終的であるものとすぐに使えるものを格納するかオブジェクト。エラーが発生するならば、このプロパティはnullに設定されます、そして、オブジェクトはツールキットで内部的に破棄されます。 |
CodecsGetInformationAsyncCompletedEventArgs.Error |
非同期動作の間、発生したかもしれない任意のエラーを格納します。GetInformationAsyncCompletedイベントが発生するこの値を確認しなければならなくて、それが有効な例外を格納しないことを確認しなければなりませんオブジェクト。 |
CodecsGetInformationAsyncCompletedEventArgs.Cancelled |
非同期動作がキャンセルされたかどうか示している値を格納します。たとえば、URLでRasterCodecs.GetInformationAsyncを使うとき、CancelAsyncを呼び出すことによって。 |
Imports Leadtools Imports Leadtools.Codecs Imports Leadtools.ImageProcessing Imports Leadtools.ImageProcessing.Color Imports Leadtools.Drawing Imports Leadtools.Svg Public Sub GetInformationAsyncCompletedExample() Dim srcFileName As String = Path.Combine(LEAD_VARS.ImagesDir, "Image1.cmp") Dim uri As New Uri(srcFileName) Dim codecs As New RasterCodecs() ' Now get information about the file asynchronously AddHandler codecs.GetInformationAsyncCompleted, AddressOf GetInformationAsyncCompletedExample_GetInformationAsyncCompleted Dim imageInfoObject As Object = codecs.GetInformationAsync(uri, True, 1, Nothing) ' 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. End Sub Private Sub GetInformationAsyncCompletedExample_GetInformationAsyncCompleted(ByVal sender As Object, ByVal e As CodecsGetInformationAsyncCompletedEventArgs) If e.Cancelled Then Console.WriteLine("User canceled") ElseIf Not IsNothing(e.Error) Then Console.WriteLine("Error: " + e.Error.Message) Else ' Get the image info Dim info As CodecsImageInfo = DirectCast(e.Info, CodecsImageInfo) Console.WriteLine("Image info obtainted asynchronously:\n{0}", info.ToString()) info.Dispose() End If ' Unsubscribe to the event and dispose the RasterCodecs object Dim codecs As RasterCodecs = DirectCast(sender, RasterCodecs) RemoveHandler codecs.GetInformationAsyncCompleted, AddressOf GetInformationAsyncCompletedExample_GetInformationAsyncCompleted codecs.Dispose() End Sub Public NotInheritable Class LEAD_VARS Public Const ImagesDir As String = "C:\Users\Public\Documents\LEADTOOLS Images" End Class
using Leadtools; using Leadtools.Codecs; using Leadtools.ImageProcessing; using Leadtools.ImageProcessing.Color; using Leadtools.Svg; public void GetInformationAsyncCompletedExample() { string srcFileName = Path.Combine(LEAD_VARS.ImagesDir, "Image1.cmp"); Uri uri = new Uri(srcFileName); RasterCodecs codecs = new RasterCodecs(); // Now get information about the file asynchronously codecs.GetInformationAsyncCompleted += new EventHandler<CodecsGetInformationAsyncCompletedEventArgs>(GetInformationAsyncCompletedExample_GetInformationAsyncCompleted); object imageInfoObject = 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. } private void GetInformationAsyncCompletedExample_GetInformationAsyncCompleted(object sender, CodecsGetInformationAsyncCompletedEventArgs e) { if (e.Cancelled) { Console.WriteLine("User canceled"); } else if (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 codecs = sender as RasterCodecs; codecs.GetInformationAsyncCompleted -= new EventHandler<CodecsGetInformationAsyncCompletedEventArgs>(GetInformationAsyncCompletedExample_GetInformationAsyncCompleted); codecs.Dispose(); } static class LEAD_VARS { public const string ImagesDir = @"C:\Users\Public\Documents\LEADTOOLS Images"; }