public TokenResult GetToken()
        {
            WebForm web = new WebForm(new Uri(ServiceRequestUri), CallbackUrl);
            // start in new thread
            var t = new Thread(delegate() { token = web.Start(); });
            t.SetApartmentState(ApartmentState.STA);
            t.Start();
            t.Join();
            //while (t.IsAlive)
            //{
            //    Thread.Sleep(5000);
            //}

            return token;
        }
        public TokenResult GetToken()
        {
            WebForm web = new WebForm(new Uri(ServiceRequestUri), CallbackUrl);
            // start in new thread
            var t = new Thread(delegate() { token = web.Start(); });

            t.SetApartmentState(ApartmentState.STA);
            t.Start();
            t.Join();
            //while (t.IsAlive)
            //{
            //    Thread.Sleep(5000);
            //}

            return(token);
        }