Example #1
0
        //Usage: BITS job name, file path, "file args"
        private void persist(string remote, string filePath, string cmdArgs)
        {
            string name = "Microsoft Example BD_1";

            jo.downloadFile(name, remote, filePath); //initial download, completes

            mgr.CreateJob(name, BITS.BG_JOB_TYPE.BG_JOB_TYPE_DOWNLOAD, out jobGuid, out job);

            job.AddFile(remote, filePath);
            jo.commandExec(job, filePath, cmdArgs);
            job.SetMinimumRetryDelay(30);

            job.Resume(); // this downloads the file and keeps it in a persistent running state
            //System.Threading.Thread.Sleep(1000);
            //job.Suspend();
        }
        private void SetJobProperties(BITS.IBackgroundCopyJob job)
        {
            //TODO  - BITS_JOB_TRANSFER_POLICY = BITS_JOB_TRANSFER_POLICY_ALWAYS

            if (job is BITS5.IBackgroundCopyJob5 job5)
            {
                var value = new BITS5.BITS_JOB_PROPERTY_VALUE
                {
                    Enable = 1
                };
                job5.SetProperty(BITS5.BITS_JOB_PROPERTY_ID.BITS_JOB_PROPERTY_DYNAMIC_CONTENT, value);

                var value_high_perf = new BITS5.BITS_JOB_PROPERTY_VALUE
                {
                    Enable = 0
                };
                job5.SetProperty(BITS5.BITS_JOB_PROPERTY_ID.BITS_JOB_PROPERTY_HIGH_PERFORMANCE, value_high_perf);
            }

            job.SetPriority(BITS.BG_JOB_PRIORITY.BG_JOB_PRIORITY_FOREGROUND);
            job.SetMinimumRetryDelay(RETRY_DELAY_SECONDS);
        }