예제 #1
0
        public override void Run(bool runChildren)
        {
            if (runChildren)
            {
                SetText(GetText());
                if (TaskLTSV.NullIsEmpty().Length > 0)
                {
                    TaskParameterList.LTSV = TaskLTSV.Convert(this);
                }
                if (TaskLTSVFile.NullIsEmpty().Length > 0)
                {
                    TaskParameterList.FileName = TaskLTSVFile.Convert(this);
                }
                TaskParameterList.Load(this);
                List <Task> list = new List <Task>();

                KeyValueStore key = new KeyValueStore();
                foreach (var item in this.Children)
                {
                    key.AddChildren(item);
                }
                var    xaml = key.ToXAML();
                string err;
                if (TaskParameterList.Count > 0)
                {
                    foreach (var item in TaskParameterList)
                    {
                        var r = (KeyValueStore)RawlerBase.Parse(xaml, out err);
                        foreach (var keyvalue in item)
                        {
                            r.SetKeyValue(keyvalue.Key, keyvalue.Value);
                        }
                        r.SetParent(this.Parent);
                        list.Add(Task.Factory.StartNew(() => r.Run()));
                    }
                }
                else
                {
                    for (int i = 0; i < TaskNum; i++)
                    {
                        var r = (KeyValueStore)RawlerBase.Parse(xaml, out err);
                        r.SetParent(this.Parent);
                        list.Add(Task.Factory.StartNew(() => r.Run()));
                    }
                }
                Task.WaitAll(list.ToArray());
            }
        }