C# TimerCallback return value error
<p>When I use <kbd>F11</kbd> debug, <code>NetStatus</code> value is <code>true</code>, but when I use <kbd>F5</kbd> debug, <code>NetStatus</code> value is <code>false</code>. Why? How do I fix it?</p>

<p>I don't know what time the <code>_connect</code> value changes.
Is this a multi-threading synchronization issue?</p>

<pre><code>using System;
using System.Collections.Generic;
using System.Text;
using System.Net;
using System.Net.Sockets;
using System.Threading;

namespace conn
{
        class Program
    {
            static void Main(string[] args)
            {
                    wait_conn();
            }


            private static void wait_conn()
            {
                    bool NetStatus = false;
                    string DataS = "127.0.0.1";

                    CheckIpConn conn = new CheckIpConn();

                    conn.CheckIp(DataS);

                    //Thread.Sleep(3000);

                    NetStatus = conn.Connected;

                    if (!NetStatus)
                            Console.WriteLine(conn.Connected.ToString());
                    Console.Read();
            }
    }


    public class CheckIpConn
    {
            private int _port = 135;
            private volatile bool _connect;
            private IPEndPoint _iPEndPoint;
            private TcpClient _client;
            private TimerCallback _timerCallBack;
            private System.Threading.Timer _timer;

            public bool Connected
            {
                    get { return _connect; }
            }


            public void CheckIp(string Ip)
            {
                    _iPEndPoint = new IPEndPoint(IPAddress.Parse(Ip), _port);
                    _timerCallBack = new TimerCallback(CheckConnect);
                    _timer = new System.Threading.Timer(_timerCallBack, null, 10, 1000);
                    _timer.Dispose();

            }

            public void CheckConnect(object o)
            {
                    try
                    {
                            _client = new TcpClient();
                            _client.Connect(_iPEndPoint);
                            _connect = true;
                            _client.Close();
                    }
                    catch
                    {
                            _connect = false;
                    }
            }


    }
}
</code></pre>
