invite: start new thread to not freeze the UI when accepting

This commit is contained in:
Hylke Bons 2012-07-27 18:00:55 +02:00
parent a323575d5c
commit 1c350575a3
3 changed files with 15 additions and 12 deletions

View file

@ -29,7 +29,7 @@
<body> <body>
<div> <div>
<b>hbons's stuff</b> on <b>Github</b> <b>hbons's stuff</b> on <b>Github</b>
<a href="sparkleshare://www.sparkleshare.org/test-invite.xml"> <a href="sparkleshare://raw.github.com/hbons/SparkleShare/master/SparkleShare/Common/HTML/protocol-handler-test/invite.xml">
<img src="add-to-sparkleshare-button.png" alt="Add to SparkleShare"> <img src="add-to-sparkleshare-button.png" alt="Add to SparkleShare">
</a> </a>
</div> </div>

View file

@ -417,11 +417,11 @@ namespace SparkleShare {
// fully downloaded yet, so we try to read it several times // fully downloaded yet, so we try to read it several times
int tries = 0; int tries = 0;
while (!invite.IsValid) { while (!invite.IsValid) {
Thread.Sleep (250); Thread.Sleep (100);
invite = new SparkleInvite (args.FullPath); invite = new SparkleInvite (args.FullPath);
tries++; tries++;
if (tries > 20) { if (tries > 10) {
AlertNotificationRaised ("Oh noes!", "This invite seems screwed up..."); AlertNotificationRaised ("Oh noes!", "This invite seems screwed up...");
break; break;
} }

View file

@ -429,17 +429,20 @@ namespace SparkleShare {
ChangePageEvent (PageType.Syncing, null); ChangePageEvent (PageType.Syncing, null);
if (!PendingInvite.Accept ()) { new Thread (() => {
ChangePageEvent (PageType.Error, null); if (!PendingInvite.Accept ()) {
return; ChangePageEvent (PageType.Error, null);
} return;
}
Program.Controller.FolderFetched += InvitePageFetchedDelegate; Program.Controller.FolderFetched += InvitePageFetchedDelegate;
Program.Controller.FolderFetchError += InvitePageFetchErrorDelegate; Program.Controller.FolderFetchError += InvitePageFetchErrorDelegate;
Program.Controller.FolderFetching += SyncingPageFetchingDelegate; Program.Controller.FolderFetching += SyncingPageFetchingDelegate;
Program.Controller.StartFetcher (PendingInvite.Address, PendingInvite.Fingerprint, Program.Controller.StartFetcher (PendingInvite.Address, PendingInvite.Fingerprint,
PendingInvite.RemotePath, PendingInvite.AnnouncementsUrl, false); // TODO: checkbox on invite page PendingInvite.RemotePath, PendingInvite.AnnouncementsUrl, false); // TODO: checkbox on invite page
}).Start ();
} }
// The following private methods are // The following private methods are