private void onCompleted(NativeActivityContext context, ActivityInstance completedInstance)
 {
     try
     {
         // Thread.Sleep(500);
         activitycount = activitycount + 1;
         if (activitycount >= Activities.Count)
         {
             if (ResetApplication)
             {
                 //Thread.Sleep(5000); //replace by appropriate logic
                 Reset();
                 //   Thread.Sleep(7000); //replace by appropriate logic
             }
             return;
         }
         var itemInner = Activities[activitycount];
         if (itemInner is ActivityExtended)
         {
             ActivityExtended extended         = (ActivityExtended)itemInner;
             string           strAppIdToAttach = ApplicationIDToAttach.Get(context);
             string           strTitleorUrl    = TitleOrUrlToAttach.Get(context);
             extended.ExecuteMe(context, strAppIdToAttach, strTitleorUrl);
         }
         //Thread.Sleep(500);
         context.ScheduleActivity(itemInner, onCompleted);
     }
     catch (Exception ex)
     {
         Logger.Log.Logger.LogData(ex.Message, LogLevel.Error);
     }
 }
        protected override void Execute(NativeActivityContext context)
        {
            try
            {
                string strAppIdToAttach      = ApplicationIDToAttach.Get(context);
                string strTitleOrUrlToAttach = TitleOrUrlToAttach.Get(context);



                if ((strAppIdToAttach == null) && (strTitleOrUrlToAttach == null))
                {
                    Logger.Log.Logger.LogData("''Attach by ApplicationID'  or 'Attach by Title/URL' Not Set", LogLevel.Error);
                    context.Abort();
                }
                activitycount = 0;
                var item = Activities[activitycount];
                if (item is ActivityExtended)
                {
                    ActivityExtended extended = (ActivityExtended)item;

                    extended.ExecuteMe(context, strAppIdToAttach, strTitleOrUrlToAttach);
                }

                context.ScheduleActivity(item, onCompleted, onFaulted);

                //  context.ScheduleActivity(item, onCompleted, onFaulted);
            }
            catch (Exception ex)
            {
                Logger.Log.Logger.LogData(ex.Message + " in activity AttachApplication", Logger.LogLevel.Error);
                if (!ContinueOnError)
                {
                    context.Abort();
                }
            }
        }