Checking if replication has completed on Mobile

Edit : I solved the issue. it had something to do with in what order i replicated multiple databases. here is my solution.

    private void replicateDatabase(params string[] databases)
    {


        #region db

        var repcntr = 1;

        UserDialogs.Instance.Loading("Replicating Databases");

        foreach (string name in databases)
        {
            Uri url = new Uri("ws://xx.xx.xx.xxx:xxxx/" + name);
            var db = new Database(name);

            var config = new ReplicatorConfiguration
            (
                 db,
                 url

            );

            var replication = new Replicator(config);
            try
            {
                replication.Start();
            }
            catch (Exception ex)
            {
                var test = ex;
            }
            replication.StatusChanged += (sender, e) =>
            {
                if (e.Status.Activity == ReplicatorActivityLevel.Stopped)
                {
                    repcntr ++;
                    Console.WriteLine("Replication has completed.");
                    
                    UserDialogs.Instance.Toast(String.Format("{0}/{1} - Replication completed on {2}", repcntr-1, databases.Count(), name));

                    if (repcntr == databases.Count() + 1)
                    {
                        UserDialogs.Instance.Loading().Dispose();

                        UserDialogs.Instance.Toast("Replication completed on all databases");
                    }

                    replication.Dispose();
                }
                else if (e.LastError != null)
                {
                    Exception error = e.LastError;
                    if (error != null)
                    {
                        var test = error;
                    }
                }
                Console.WriteLine(replication.Status.ToString());
            };

            db.Dispose();

            var db2 = new Database(name);
        }

        #endregion

    }

I hope this might be of some use to someone :smiley:

However. At any random moment the replications comes to a halt and gets into some kind of loop doing whatever and keeps spewing this stacktrace. It does not crash. It just stops replicating. (This happens on databases of ± 2000 documents). It also occurs that the replication sometimes happens perfectly, but that happens rarely.

Stacktrace:

The thread 'Unknown' (0x22) has exited with code 0 (0x0).
08-18 15:44:24.407 D/Mono    (15921): [0x6b10dc98] worker unparking, timeout? yes interrupted? no
08-18 15:44:24.407 D/Mono    (15921): [0x6b10dc98] worker finishing
08-18 15:44:24.407 D/Mono    (15921): [0x6690ae48] worker unparking, timeout? no interrupted? no
08-18 15:44:24.407 D/Mono    (15921): [0x6690ae48] worker parking
08-18 15:44:24.407 D/Mono    (15921): [0x668bec38] worker unparking, timeout? no interrupted? no
08-18 15:44:24.407 D/Mono    (15921): [0x668bec38] worker parking
08-18 15:44:24.407 D/Mono    (15921): [0x668ba910] worker unparking, timeout? no interrupted? no
08-18 15:44:24.407 D/Mono    (15921): [0x668ba910] worker parking
08-18 15:44:24.407 D/Mono    (15921): [0x67db0740] worker unparking, timeout? no interrupted? no
08-18 15:44:24.407 D/Mono    (15921): [0x67db0740] worker parking
08-18 15:44:24.407 D/Mono    (15921): [0x6b4e4cc8] worker unparking, timeout? no interrupted? no
08-18 15:44:24.407 D/Mono    (15921): [0x6b4e4cc8] worker parking
08-18 15:44:24.407 D/Mono    (15921): [0x6ad595c0] worker unparking, timeout? no interrupted? no
08-18 15:44:24.407 D/Mono    (15921): [0x6ad595c0] worker parking
Thread finished: <Thread Pool> #33
08-18 15:44:24.407 D/Mono    (15921): [0x6ad163a8] worker unparking, timeout? no interrupted? no
08-18 15:44:24.407 D/Mono    (15921): [0x6ad163a8] worker parking
08-18 15:44:24.417 D/Mono    (15921): [0x6690ae48] worker unparking, timeout? no interrupted? no
08-18 15:44:24.417 D/Mono    (15921): [0x6690ae48] worker parking
The thread 'Unknown' (0x21) has exited with code 0 (0x0).
08-18 15:44:29.617 D/Mono    (15921): [0x6ad595c0] worker unparking, timeout? yes interrupted? no
08-18 15:44:29.617 D/Mono    (15921): [0x6ad595c0] worker finishing
08-18 15:44:29.617 D/Mono    (15921): [0x6690ae48] worker unparking, timeout? no interrupted? no
08-18 15:44:29.617 D/Mono    (15921): [0x6690ae48] worker parking
08-18 15:44:29.617 D/Mono    (15921): [0x668bec38] worker unparking, timeout? no interrupted? no
08-18 15:44:29.617 D/Mono    (15921): [0x668bec38] worker parking
08-18 15:44:29.617 D/Mono    (15921): [0x668ba910] worker unparking, timeout? no interrupted? no
08-18 15:44:29.617 D/Mono    (15921): [0x668ba910] worker parking
08-18 15:44:29.617 D/Mono    (15921): [0x67db0740] worker unparking, timeout? no interrupted? no
08-18 15:44:29.617 D/Mono    (15921): [0x67db0740] worker parking
08-18 15:44:29.617 D/Mono    (15921): [0x6b4e4cc8] worker unparking, timeout? no interrupted? no
08-18 15:44:29.617 D/Mono    (15921): [0x6b4e4cc8] worker parking
08-18 15:44:29.627 D/Mono    (15921): [0x6ad163a8] worker unparking, timeout? no interrupted? no
Thread finished: <Thread Pool> #30
08-18 15:44:29.627 D/Mono    (15921): [0x6ad163a8] worker parking
08-18 15:44:29.627 D/Mono    (15921): [0x6690ae48] worker unparking, timeout? no interrupted? no
08-18 15:44:29.627 D/Mono    (15921): [0x6690ae48] worker parking
The thread 'Unknown' (0x1e) has exited with code 0 (0x0).

Ill make a separate topic on this issue.

Cheers!