c# - asynchronous beginwrite endwrite Unity (net 2.0) -


i'm trying figure out proper way write bytes (in case recorded .wav file) harddisk in asynchronous way.

i'm using unity far know i'm limited using filestream.beginwrite , endwrite.

what got far seems working, i'm worried that, because of lack of experience asynchronous calls i'm not closing filestream after it's done, leaking memory.

i'm starting beginwrite so:

object t = null;  filestream.beginwrite(bytesdata, 0, bytesdata.length, new  asynccallback(endwritecallback),  t);  

then i've got endwritecallback has this:

public static void endwritecallback(iasyncresult e){     filestream fs = e.asyncstate filestream;     fs.endwrite(e); } 

is enough? again, seems working alright, feel i'll have call filestream.close() somewhere.

thanks in advance

as @christophkn mentioned in comment above, fs.dispose() best way release resources.


Comments

Popular posts from this blog

javascript - jQuery: Add class depending on URL in the best way -

caching - How to check if a url path exists in the service worker cache -

Redirect to a HTTPS version using .htaccess -