.net - how to call public sub from private shared sub vb.net -


this writing data same file multithreading

dim _readwritelock readerwriterlockslim = new readerwriterlockslim      private sub writedatatofile(byval s string)         ' set status locked          _readwritelock.enterwritelock()         try             ' append text file             dim sw streamwriter = file.appendtext("textfile.txt")             sw.writeline(s)             sw.close()                     ' release lock             _readwritelock.exitwritelock()         end try     end sub 

this getting asynchronous response

private shared sub getresponsecallback(byval asynchronousresult iasyncresult)       dim response httpwebresponse = ctype(request.endgetresponse(asynchronousresult),  _        httpwebresponse)  writedatatofile(response.headers.tostring)  end sub 

whene call writedatatofile getresponsecallback error : cannot refer instance member of class within shared method or shared member initializer without explicit instance of class

how can write safety multithreads same text file asynchronous response ?

you cannot call instance method shared (static) method. saying, "i want call method operates on particular instance of object method doesn't care object instances" - how shared method able that?

you need change getresponsecallback instance (removed shared modifier).


Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

Python ctypes access violation with const pointer arguments -