Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

I'll get to the point.

 

Here's my code for calling conv.Convert asynchronously:

[csharp]

ToHTMLConverter conv = new ToHTMLConverter();

ASyncConvert aconv = new ASyncConvert(conv.Convert);

AsyncCallback aconvcallback = new AsyncCallback(this.HandleConverterCallback);

IAsyncResult result = aconv.BeginInvoke(fullpath, outfilename, out sErrMsg, true, aconvcallback, null);

[/csharp]

 

Here's my code defining HandleConverterCallback:

[csharp]

private void HandleConverterCallback(IAsyncResult result)

{

try

{

object sErrMsg;

ASyncConvert aconv = (ASyncConvert)result.AsyncState;

bool convertresult = aconv.EndInvoke(out sErrMsg, result);

}

catch (Exception ex)

{

// Problem occured when handling callback.

}

}

[/csharp]

 

The question is why is the result.AsyncState returns null? This has never happened before. I usually get the aconv object so that I can call the EndInvoke method.

 

Any clues?

Amir Syafrudin
  • Administrators
Posted

In the line

IAsyncResult result = aconv.BeginInvoke(fullpath, outfilename, out sErrMsg, true, aconvcallback, null);

you are passing null as the last parameter - whatever you pass in here is what you get with the IAsyncResult.AsyncState property.

Posting Guidelines FAQ Post Formatting

 

Intellectuals solve problems; geniuses prevent them.

-- Albert Einstein

Posted
In the line

IAsyncResult result = aconv.BeginInvoke(fullpath, outfilename, out sErrMsg, true, aconvcallback, null);

you are passing null as the last parameter - whatever you pass in here is what you get with the IAsyncResult.AsyncState property.

 

I see.

 

I cross-checked with my original reference when creating the code. Not that I don't believe in you PlausiblyDamp. I just needed to know what should I pass in the last parameter.

 

I guess I miss that part. :D

 

Before I didn't use any AsyncCallback so I didn't notice that I needed to replace that last parameter.

 

Thank you for your reply. I find it very helpful. :D

Amir Syafrudin

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...