Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #1335 from Nezz/ios_threading

Fixed some threading issues on iOS
  • Loading branch information...
commit 16d9bbf188898d7edd5b7985a1ee6c9d121d1aef 2 parents 62a1522 + 08eb088
@tomspilman tomspilman authored
Showing with 35 additions and 25 deletions.
  1. +35 −25 MonoGame.Framework/iOS/GamerServices/SignedInGamer.cs
View
60 MonoGame.Framework/iOS/GamerServices/SignedInGamer.cs
@@ -298,15 +298,19 @@ public void AwardAchievement( string achievementId )
public void DoAwardAchievement( string achievementId, double percentageComplete )
{
- GKAchievement a = new GKAchievement(achievementId);
- a.PercentComplete = percentageComplete;
- a.ReportAchievement( delegate(NSError error){
- if (error != null)
- {
- // Retain the achievement object and try again later (not shown).
- }
-
- } );
+ UIApplication.SharedApplication.InvokeOnMainThread(delegate
+ {
+ GKAchievement a = new GKAchievement(achievementId);
+ a.PercentComplete = percentageComplete;
+ a.ReportAchievement(delegate(NSError error)
+ {
+ if (error != null)
+ {
+ // Retain the achievement object and try again later (not shown).
+ }
+
+ });
+ });
}
public void AwardAchievement( string achievementId, double percentageComplete )
@@ -321,15 +325,18 @@ public void UpdateScore( string aCategory, long aScore )
{
if (IsSignedInToLive)
{
- GKScore score = new GKScore(aCategory);
- score.Value = aScore;
- score.ReportScore(delegate (NSError error)
- {
- if (error != null)
- {
- // Oh oh something went wrong.
- }
- });
+ UIApplication.SharedApplication.InvokeOnMainThread(delegate
+ {
+ GKScore score = new GKScore(aCategory);
+ score.Value = aScore;
+ score.ReportScore(delegate(NSError error)
+ {
+ if (error != null)
+ {
+ // Oh oh something went wrong.
+ }
+ });
+ });
}
}
@@ -337,13 +344,16 @@ public void ResetAchievements()
{
if (IsSignedInToLive)
{
- GKAchievement.ResetAchivements(delegate (NSError error)
- {
- if (error != null)
- {
- // Oh oh something went wrong.
- }
- });
+ UIApplication.SharedApplication.InvokeOnMainThread(delegate
+ {
+ GKAchievement.ResetAchivements(delegate(NSError error)
+ {
+ if (error != null)
+ {
+ // Oh oh something went wrong.
+ }
+ });
+ });
}
}
Please sign in to comment.
Something went wrong with that request. Please try again.