using MWS.Library;
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;

namespace MWS.Domain.Tasks.WebApi
{
    public static class WebApiServerTask
    {
        private static Thread thread = new Thread(new ThreadStart(ThreadBackground));
        private static void ThreadBackground()
        {
            try
            {
                var portName = ConfigurationManager.AppSettings["webApiHostPort"];
                //Crane crane = CacheUtil.GetCrane();
                string baseAddress = "http://*:" + portName + "/";
                Microsoft.Owin.Hosting.WebApp.Start<Startup>(url: baseAddress);
            }
            catch (Exception ex)
            {
                LogHelper.WriteLog("启动http服务出错", ex);
                //LogHelper.Error("启动http服务出错", ex);
            }

        }
        public static void Start()
        {
            thread.Start();
        }
        public static void Stop()
        {
            thread.Abort();
        }
    }
}
