Example #1
0
        public async Task <string> AsyncOPEN(List <ParamCanal> lst, string name)
        {
            var tcs = new TaskCompletionSource <string>();
            //&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
            var taskload = Task.Run(() =>
            {
                try
                {
                    loc.asyncOPEN = true;
                    Wait.Create("Анализ файла ...", true);

                    if (name != null)
                    {
                        //РЕЖИМ ЗАПУСКА ПАРСИНГА С ОБРАБОТКОЙ КОМАНД ИЛИ БЕЗ
                        bool mode = Parse.mode.with_command; string nm = " KEYOP";//по кнопке

                        if (Script.working)
                        {
                            mode = Parse.mode.not_command; nm = " MODESCRPT";
                        }                                                         //по скрипту

                        data.flag_adding_ok = false;
                        var p = new Parse(mode, nm);
                        p.PARSING_FILE(lst, name, false);
                    }
                    else
                    {
                        loc.openfile = false;
                    }

                    Thread.Sleep(300);

                    Wait.Close();

                    Script.ResetMODEApplication();

                    tcs.SetResult("ok");
                }
                catch (OperationCanceledException e)
                {
                    tcs.SetException(e);
                }
                catch (Exception e)
                {
                    tcs.SetException(e);
                }
                loc.asyncOPEN = false;
                return(tcs.Task);
            });

            //&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
            try
            {
                var result = await taskload;
                if (Task_Completed != null)
                {
                    Task_Completed();
                }
            }
            catch (Exception ex)
            {
                dialog.Show("ОШИБКА-ПАРСИНГА ФАйЛА " + ex.Message);
            }
            return(tcs.ToString());
        }
Example #2
0
        public async Task <string> AsyncOPEN(List <IPTVman.Model.ParamCanal> lst, string name)
        {
            var tcs = new TaskCompletionSource <string>();
            //&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
            var taskload = Task.Run(() =>
            {
                try
                {
                    loc.asyncOPEN = true;
                    Wait.Create("Идет анализ файла ", true);
                    mode_work_with_links = true;
                    bufferstring.Clear();
                    if (name != null)
                    {
                        Trace.WriteLine("start parsing >" + name + "<");
                        PARSING_FILE(lst, name);
                    }
                    else
                    {
                        loc.openfile = false;
                    }


                    Thread.Sleep(300);
                    Wait.Close();
                    if (Event_UpdateLIST != null)
                    {
                        Event_UpdateLIST(typefilter.normal);
                    }
                    Wait.Close();
                    bufferstring.Clear();

                    ModeWork.ResetMODEApplication();
                    if (ModeWork.OpenWindow_db_update)
                    {
                        ModeWork.OpenWindow_db_updateREADY = true;
                    }
                    if (ModeWork.OpenWindow_radio)
                    {
                        ModeWork.OpenWindow_radioREADY = true;
                    }
                    tcs.SetResult("ok");
                }
                catch (OperationCanceledException e)
                {
                    tcs.SetException(e);
                }
                catch (Exception e)
                {
                    tcs.SetException(e);
                }
                loc.asyncOPEN = false;
                return(tcs.Task);
            });

            //&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
            try
            {
                var result = await taskload;
                if (Task_Completed != null)
                {
                    Task_Completed();
                }
            }
            catch (Exception ex)
            {
                dialog.Show("ОШИБКА-ПАРСИНГА ФАйЛА " + ex.Message.ToString());
            }
            return(tcs.ToString());
        }