在C#中使用TweetSharp发布推文需要花费大量时间

在C#中使用TweetSharp发布推文需要花费大量时间,c#,.net,twitter,xna,tweetsharp,C#,.net,Twitter,Xna,Tweetsharp,我正在使用TweetSharp从我的C#应用程序发送推文。我的应用程序是一个基于XNA的游戏,在每个游戏结束时,分数会自动发送到Twitter帐户 tweet每次都会发布,没有错误,但每次都会冻结1.5秒 我用它来发布代码: twitterService.SendTweet(new SendTweetOptions { Status = status }); 减少发布时间的解决方案是什么?如果您使用.NET 4.5在新线程中运行某些内容,您可以这样做 // this is a better w

我正在使用TweetSharp从我的C#应用程序发送推文。我的应用程序是一个基于XNA的游戏,在每个游戏结束时,分数会自动发送到Twitter帐户

tweet每次都会发布,没有错误,但每次都会冻结1.5秒

我用它来发布代码:

twitterService.SendTweet(new SendTweetOptions { Status = status });

减少发布时间的解决方案是什么?

如果您使用.NET 4.5在新线程中运行某些内容,您可以这样做

// this is a better way to run something in the background
// this queues up a task on a background threadpool
await Task.Run(() => {
    twitterService.SendTweet(new SendTweetOptions { Status = status });
});

// this method of running a task in the background creates unnecessary overhead
Task.Factory.StartNew(() => {
    twitterService.SendTweet(new SendTweetOptions { Status = status });
});

您可能无法加快速度,但可以将其放入后台工作程序()中,以便程序在执行时继续运行。谢谢您的快速回答!我使用了XNA的一个更简单的特性来进行多线程处理,它的工作方式很有魅力!