我正在使用C#和google Task API开发一个窗口服务。它适用于窗口形式和C#的控制台应用程序。我的代码示例是
UserCredential credential;
using (var stream = new FileStream("client_secrets.json", FileMode.Open, FileAccess.Read))
{
credential = GoogleWebAuthorizationBroker.AuthorizeAsync(
GoogleClientSecrets.Load(stream).Secrets,
new[] { TasksService.Scope.Tasks },
"shyam.sundar525@gmail.com", CancellationToken.None, new FileDataStore("Tasks.Auth.Store")).Result;
}
// Create the service.
var service = new TasksService(new BaseClientService.Initializer()
{
HttpClientInitializer = credential,
ApplicationName = "Tasks API Sample",
});
//creating new task
var list = new TaskList();
list.Title = SampleListName;
list = service.Tasklists.Insert(list).Execute();
service.Tasks.Insert(new Task { Title = "Learn the Task API" }, list.Id).Execute();
service.Tasks.Insert(new Task { Title = "Implement a WP application using Task API" }, list.Id).Execute();
当我在任务栏中运行窗口服务时,它会使hang.Service既不停止也不运行只显示启动。 谢谢 shyams