the*_*meg 5 .net c# twitter xna tweetsharp
我正在使用TweetSharp从我的C#应用程序发送推文.我的应用程序是基于XNA的游戏,在每个游戏结束时,分数会自动发送到Twitter帐户.
每次都会发布推文而没有任何错误,但每次发布时,游戏会冻结1.5秒.
我正在使用它来发布代码:
twitterService.SendTweet(new SendTweetOptions { Status = status });
Run Code Online (Sandbox Code Playgroud)
什么可以减少发布时间的解决方案?
如果您使用 .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 });
});
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2298 次 |
| 最近记录: |