123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Runtime.InteropServices;
- using System.Text;
- namespace HPSocketCS
- {
-
-
-
-
- public enum RejectedPolicy
- {
-
-
-
- TRP_CALL_FAIL = 0,
-
-
-
- TRP_WAIT_FOR = 1,
-
-
-
- TRP_CALLER_RUN = 2,
- }
-
-
-
-
- public enum TaskBufferType
- {
-
-
-
- TBT_COPY = 0,
-
-
-
- TBT_REFER = 1,
-
-
-
- TBT_ATTACH = 2,
- }
-
-
-
-
-
-
-
- public delegate void TaskProc(IntPtr pvArg);
-
-
-
-
-
-
- public delegate void SocketTaskProc(SocketTask task);
-
-
-
-
- [StructLayout(LayoutKind.Sequential)]
- public struct SocketTask
- {
-
-
-
- public SocketTaskProc Fn;
-
-
-
- public IntPtr Sender;
-
-
-
- public IntPtr ConnId;
-
-
-
- public IntPtr Buffer;
-
-
-
- public int BufferSize;
-
-
-
- public TaskBufferType BufferType;
-
-
-
- public IntPtr WParam;
-
-
-
- public IntPtr LParam;
- }
- public class ThreadPoolSdk
- {
-
-
-
-
-
- [DllImport(Sdk.HPSOCKET_DLL_PATH, CharSet = CharSet.Ansi, SetLastError = true)]
- public static extern IntPtr Create_HP_ThreadPool();
-
-
-
-
- [DllImport(Sdk.HPSOCKET_DLL_PATH, CharSet = CharSet.Ansi, SetLastError = true)]
- public static extern void Destroy_HP_ThreadPool(IntPtr pThreadPool);
-
-
-
-
-
-
-
-
-
-
-
-
-
- [DllImport(Sdk.HPSOCKET_DLL_PATH, CharSet = CharSet.Ansi, SetLastError = true)]
- public static extern IntPtr Create_HP_SocketTaskObj(SocketTaskProc fnTaskProc, IntPtr pSender, IntPtr dwConnID, byte[] pBuffer, int iBuffLen, TaskBufferType enBuffType , IntPtr wParam , IntPtr lParam );
-
-
-
-
-
- [DllImport(Sdk.HPSOCKET_DLL_PATH, CharSet = CharSet.Ansi, SetLastError = true)]
- public static extern void Destroy_HP_SocketTaskObj(IntPtr pTask);
-
-
-
-
-
-
-
-
-
-
- [DllImport(Sdk.HPSOCKET_DLL_PATH, CharSet = CharSet.Ansi, SetLastError = true)]
- public static extern bool HP_ThreadPool_Start(IntPtr pThreadPool, uint dwThreadCount , uint dwMaxQueueSize , RejectedPolicy enRejectedPolicy , uint dwStackSize );
-
-
-
-
-
-
-
-
- [DllImport(Sdk.HPSOCKET_DLL_PATH, CharSet = CharSet.Ansi, SetLastError = true)]
- public static extern bool HP_ThreadPool_Stop(IntPtr pThreadPool, int dwMaxWait );
-
-
-
-
-
-
-
-
-
- [DllImport(Sdk.HPSOCKET_DLL_PATH, CharSet = CharSet.Ansi, SetLastError = true)]
- public static extern bool HP_ThreadPool_Submit(IntPtr pThreadPool, TaskProc fnTaskProc, IntPtr pvArg, int dwMaxWait );
-
-
-
-
-
-
-
-
- [DllImport(Sdk.HPSOCKET_DLL_PATH, CharSet = CharSet.Ansi, SetLastError = true)]
- public static extern bool HP_ThreadPool_Submit_Task(IntPtr pThreadPool, IntPtr pTask, int dwMaxWait );
-
-
-
-
-
-
-
- [DllImport(Sdk.HPSOCKET_DLL_PATH, CharSet = CharSet.Ansi, SetLastError = true)]
- public static extern bool HP_ThreadPool_AdjustThreadCount(IntPtr pThreadPool, int dwNewThreadCount);
-
-
-
-
-
- [DllImport(Sdk.HPSOCKET_DLL_PATH, CharSet = CharSet.Ansi, SetLastError = true)]
- public static extern bool HP_ThreadPool_HasStarted(IntPtr pThreadPool);
-
-
-
-
-
- [DllImport(Sdk.HPSOCKET_DLL_PATH, CharSet = CharSet.Ansi, SetLastError = true)]
- public static extern ServiceState HP_ThreadPool_GetState(IntPtr pThreadPool);
-
-
-
-
-
- [DllImport(Sdk.HPSOCKET_DLL_PATH, CharSet = CharSet.Ansi, SetLastError = true)]
- public static extern uint HP_ThreadPool_GetQueueSize(IntPtr pThreadPool);
-
-
-
-
-
- [DllImport(Sdk.HPSOCKET_DLL_PATH, CharSet = CharSet.Ansi, SetLastError = true)]
- public static extern int HP_ThreadPool_GetThreadCount(IntPtr pThreadPool);
-
-
-
-
-
- [DllImport(Sdk.HPSOCKET_DLL_PATH, CharSet = CharSet.Ansi, SetLastError = true)]
- public static extern uint HP_ThreadPool_GetMaxQueueSize(IntPtr pThreadPool);
-
-
-
-
-
- [DllImport(Sdk.HPSOCKET_DLL_PATH, CharSet = CharSet.Ansi, SetLastError = true)]
- public static extern RejectedPolicy HP_ThreadPool_GetRejectedPolicy(IntPtr pThreadPool);
- }
- }
|