Skip to content

thread leak #52

@Hello-Mango

Description

@Hello-Mango

Hi, i'm using SocketIoClientDotNet for .Net 4.0 and i have some problems. This example code make thread leak. the thread is more and more,and follow the source code,I find the method run in Heartbeat_net35.cs is not release thread,and now I Comment this method,it is work well,but i don't know this will have any problem,my code is here
`public void Connect()
{
socket = IO.Socket(GlobalStatic.PRINTCONFIG.HeartHOST.host, new IO.Options()
{
Reconnection = true,
ReconnectionDelay = 1000,
Transports = new List() { "websocket" },
Path = GlobalStatic.PRINTCONFIG.HeartHOST.path
});

        socket.On(Socket.EVENT_CONNECT, () =>
        {

            JObject jObject = JObject.Parse(Newtonsoft.Json.JsonConvert.SerializeObject(new
            {
                companyId = GlobalStatic.COMPANY.COMPANY_ID,
                token = GlobalStatic.TOKEN,
                hostId = GlobalStatic.HOST_ID,
                hostName = GlobalStatic.HOST_NAME,
                printerNames = GlobalStatic.HOSTINFO.PrinterName,
                source = "assistant",
                userId = GlobalStatic.UserDomain.user.USER_ID
            }));
            socket.Emit("authentication", jObject);
            Debug.WriteLine("authentication");

            socket.On(Socket.EVENT_DISCONNECT, (data) =>
            {
                Debug.WriteLine("heart disconnect" + data);
                flag = false;
                OnConnectionStatus?.Invoke(flag);
                socket.Disconnect();
            });
            socket.On("authenticated", (obj) =>
            {
                flag = true;
                OnConnectionStatus?.Invoke(flag);
                Debug.WriteLine("success:" + obj);
            });
            socket.On("unauthorized", (obj) =>
            {
                Debug.WriteLine("fail" + obj);
                socket.Disconnect();
            });

            socket.On("logOut", (obj) =>
            {
                OnLogOut?.Invoke();
            });
        });
    }

`

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions