M
Mobile Boy 36
Hi all,
I'm using a ping class for a couple of months. Everything worked fine. All
class methods were declared as shared (static in c#) methods.
Now I want to make the class threadsafe, so I started to remove the shared
methods and made a 'normal' class of it, which has to be instantiated. The
class is using a couple of API calls, under which LocalAlloc and LocalFree.
These 2 functions do only work if declared as shared methods. Why?
<System.Runtime.InteropServices.DllImport("coredll")> _
Private Shared Function LocalAlloc(ByVal Flags As Integer, ByVal
size As Integer) As System.IntPtr
End Function
<System.Runtime.InteropServices.DllImport("coredll")> _
Private Shared Function LocalFree(ByVal pMem As System.IntPtr) As
System.IntPtr
End Function
What do I have to change? Would my class be threadsafe if LocalAlloc and
LocalFree are declared as shared methods?
Keep in mind, my aim is a threadsafe class. I want to avoind using sync
objects...
Any help would be greatly appreciated
Best regards
I'm using a ping class for a couple of months. Everything worked fine. All
class methods were declared as shared (static in c#) methods.
Now I want to make the class threadsafe, so I started to remove the shared
methods and made a 'normal' class of it, which has to be instantiated. The
class is using a couple of API calls, under which LocalAlloc and LocalFree.
These 2 functions do only work if declared as shared methods. Why?
<System.Runtime.InteropServices.DllImport("coredll")> _
Private Shared Function LocalAlloc(ByVal Flags As Integer, ByVal
size As Integer) As System.IntPtr
End Function
<System.Runtime.InteropServices.DllImport("coredll")> _
Private Shared Function LocalFree(ByVal pMem As System.IntPtr) As
System.IntPtr
End Function
What do I have to change? Would my class be threadsafe if LocalAlloc and
LocalFree are declared as shared methods?
Keep in mind, my aim is a threadsafe class. I want to avoind using sync
objects...
Any help would be greatly appreciated
Best regards