小编use*_*846的帖子

C#get和Thread类只工作两次,我不知道确切

namespace LEDServer
{

    public class Weather
    {
        string weathervalue, weatherexplain, temperature;
        int temp;
        public void DoWork()
        {
            while (!_shouldStop)
            {
                try
                {
                    getWeather();
                }
                catch (Exception e)
                {
                }
                Thread.Sleep(5000);

            }
            Console.WriteLine("worker thread: terminating gracefully.");
        }
        public void RequestStop()
        {
            _shouldStop = true;
        }
        // Volatile is used as hint to the compiler that this data
        // member will be accessed by multiple threads.
        private volatile bool _shouldStop;

        public static void startgetWeather()
        {
            Weather weather = new Weather();
            Thread workerThread …
Run Code Online (Sandbox Code Playgroud)

c# api multithreading asyncsocket

0
推荐指数
1
解决办法
99
查看次数

标签 统计

api ×1

asyncsocket ×1

c# ×1

multithreading ×1