Esempio n. 1
0
        static void Main(string[] args)
        {
            //DistributedLock.Config("localhost","wechat");

            /*MonitorAction ma = new MonitorAction();
             * Monitor m = new Monitor(ma.func);
             * m.Increse();
             * ma.Print();*/

            /*for (int i = 0; i < 10; i++)
             * {
             *  NetTest();
             * }*/
            MultiThread.Request(false);
            MultiThread.LockTest(false);
            MultiThread.LockAndUnlock(false);

            /*Console.WriteLine(StringTransform.StylePrice(12233.444));
             * Console.WriteLine(StringTransform.DigitalToChinese(101010101));
             * Console.WriteLine("a" + 1 + 2);*/

            /*var html = File.Open("/Temp/temp.html", FileMode.Open);
             * var buf = new byte[html.Length];
             * html.Read(buf, 0, buf.Length);
             * string h = Encoding.UTF8.GetString(buf);
             * //string temp = @"<html><h>aaaaaa</h>\n<p>bbbbbb</p></html>";
             * PdfHelper.HtmlToPdf(h);*/
            //html.Close();

            List <A> list = new List <A>
            {
                new A {
                    a = "a", b = "a"
                },
                new A {
                    a = "b", b = "b"
                },
                new A {
                    a = "c", b = "c"
                }
            };

            var item = list[1];

            list.ForEach(_ => {
                if (_.a == "b")
                {
                    list.Remove(_);
                }
            });
            list.ForEach(_ => Console.WriteLine($"{_.a} {_.b}"));

            var mi = typeof(List <string>).GetMethod("ToString");

            //Console.WriteLine(_lock.ScriptTest());

            //AsyncTest.TestAsync(true);

            //Console.WriteLine("Finished!");
        }
Esempio n. 2
0
        public BitmapSource RenderImageSource(ILUT lut)
        {
            bool render = false;

            if (_bitmap == null)
            {
                _pixels = new PinnedIntArray(ScaledData.Width * ScaledData.Height);
                _bitmap = new WriteableBitmap(ScaledData.Width, ScaledData.Height);
                render  = true;
            }
            if (_applyLut && lut != null && !lut.IsValid)
            {
                lut.Recalculate();
                render = true;
            }
            if (render)
            {
                ScaledData.Render((_applyLut ? lut : null), _pixels.Data);
            }

            MultiThread.For(0, _pixels.Count, delegate(int i) { _bitmap.Pixels[i] = _pixels.Data[i]; });
            _bitmap.Rotate(_rotation);
            if (_flipX)
            {
                _bitmap.Flip(WriteableBitmapExtensions.FlipMode.Horizontal);
            }
            if (_flipY)
            {
                _bitmap.Flip(WriteableBitmapExtensions.FlipMode.Vertical);
            }

            _bitmap.Invalidate();

            return(_bitmap);
        }
 private void button1_Click(object sender, EventArgs e)
 {
     for (int i = 0; i < 10000; i++)
     {
         ThreadPool.QueueUserWorkItem(o => MultiThread.SomeMethod());
     }
 }
Esempio n. 4
0
    public static void IGT(int delay, string path)
    {
        MakeSave();
        IGTResults res = Gsc.IGTCheckParallel(MultiThread.MakeThreads <Gold>(8), 120, new GscIntroSequence(delay, GscStrat.GfSkip, GscStrat.TitleSkip, GscStrat.Continue), 60, gb => gb.Execute(path) == gb.OverworldLoopAddress);

        Console.WriteLine(res.TotalSuccesses + " (RNG: " + res.RNGSuccesses(10) + ")");
    }
        public static byte[] RescaleColor32(byte[] input, int inputWidth, int inputHeight, int outputWidth, int outputHeight)
        {
            byte[] output = new byte[outputWidth * outputHeight * 4];

            double xF = (double)inputWidth / (double)outputWidth;
            double yF = (double)inputHeight / (double)outputHeight;

            int xMax = inputWidth - 1;
            int yMax = inputHeight - 1;

            unchecked {
                MultiThread.For(0, outputHeight, 1, delegate(int y) {
                    double oy0 = y * yF;
                    int oy1    = (int)oy0;                  // rounds down
                    int oy2    = (oy1 == yMax) ? oy1 : oy1 + 1;

                    double dy1 = oy0 - oy1;
                    double dy2 = 1.0 - dy1;

                    int yo0 = outputWidth * y * 4;
                    int yo1 = inputWidth * oy1 * 4;
                    int yo2 = inputWidth * oy2 * 4;

                    double ox0, dx1, dx2;
                    int ox1, ox2;

                    for (int x = 0, px = 0; x < outputWidth; x++)
                    {
                        ox0 = x * xF;
                        ox1 = (int)ox0;
                        ox2 = (ox1 == xMax) ? ox1 : ox1 + 1;

                        dx1 = ox0 - ox1;
                        dx2 = 1.0 - dx1;

                        output[yo0 + px] =
                            (byte)((dy2 * ((dx2 * input[yo1 + ox1]) + (dx1 * input[yo1 + ox2]))) +
                                   (dy1 * ((dx2 * input[yo2 + ox1]) + (dx1 * input[yo2 + ox2]))));
                        px++; ox1++; ox2++;

                        output[yo0 + px] =
                            (byte)((dy2 * ((dx2 * input[yo1 + ox1]) + (dx1 * input[yo1 + ox2]))) +
                                   (dy1 * ((dx2 * input[yo2 + ox1]) + (dx1 * input[yo2 + ox2]))));
                        px++; ox1++; ox2++;

                        output[yo0 + px] =
                            (byte)((dy2 * ((dx2 * input[yo1 + ox1]) + (dx1 * input[yo1 + ox2]))) +
                                   (dy1 * ((dx2 * input[yo2 + ox1]) + (dx1 * input[yo2 + ox2]))));
                        px++; ox1++; ox2++;

                        output[yo0 + px] =
                            (byte)((dy2 * ((dx2 * input[yo1 + ox1]) + (dx1 * input[yo1 + ox2]))) +
                                   (dy1 * ((dx2 * input[yo2 + ox1]) + (dx1 * input[yo2 + ox2]))));
                        px++; ox1++; ox2++;
                    }
                });
            }

            return(output);
        }
Esempio n. 6
0
        public void Render(int[] pixels, int width, int height)
        {
            byte[] data = null;

            if (_scaledData == null)
            {
                if (_scale == 1.0)
                {
                    _scaledData = _originalData;
                }
                else
                {
                    int w = (int)(_originalData.Width * _scale);
                    int h = (int)(_originalData.Height * _scale);
                    data        = BilinearInterpolation.RescaleGrayscale(_originalData.Data, _originalData.Width, _originalData.Height, w, h);
                    _scaledData = new GrayscalePixelDataU8(w, h, data);
                }
            }

            data = _scaledData.Data;

            int ox = (int)(_offsetX * _scale);
            int oy = (int)(_offsetY * _scale);

            MultiThread.For(0, _scaledData.Height, y => {
                for (int i = _scaledData.Width * y, e = i + _scaledData.Width; i < e; i++)
                {
                    if (data[i] > 0)
                    {
                        int p     = (oy * width) + ox + i;
                        pixels[p] = _color;
                    }
                }
            });
        }
Esempio n. 7
0
        static void Main(string[] args)
        {
            string path        = @"C:\Users\vtsvetkov\source\repos\pkk_5_parser\pkk_5_parser\resourses\test.xlsx";
            int    lenghtOfRow = 500;
            int    Flows       = 6;
            string driverPath  = @"C:\Users\vtsvetkov\source\repos\pkk_5_parser";

            //ExcelApp(path, driverPath, lenghtOfRow, Flows);

            Console.WriteLine(Error_log.Error_TimeStamp());

            //ExcelApp excelApp = new ExcelApp(path, "A", 2);

            var list = Tests.testElem500().ToList();

            //Parser parser = new Parser(driverPath, list);
            //parser.parser();

            MultiThread multiThread = new MultiThread(list, 4, 50, driverPath);

            multiThread.ThreadMaster();

            Console.WriteLine(Error_log.Error_TimeStamp());
            var qwe = list.Where(p => p.oks.type.Contains("Exception"));

            //Console.WriteLine("WIN");

            Console.Read();
        }
Esempio n. 8
0
    // Start is called before the first frame update
    void Start()
    {
        Core.AddEventListener("creatgo", CreatAGameObjectInScene);

        MultiThread mt = new MultiThread();

        mt.CreatAThread();
    }
Esempio n. 9
0
    public static void Start()
    {
        Yellow[] gbs = MultiThread.MakeThreads <Yellow>(8, "baseSaves/yellow_moon_backup.sav");
        Yellow   gb  = gbs[0];

        gb.Show();
        new RbyIntroSequence().Execute(gb);

        RbyMap map1 = gb.Maps[60];
        RbyMap map2 = gb.Maps[61];

        Pathfinding.GenerateEdges <RbyMap, RbyTile>(gb, 0, map2[12, 9], Action.Up | Action.Down | Action.Left | Action.Right | Action.A);

        map1[21, 16].GetEdge(0, Action.Down).NextTile  = map2[21, 17];
        map1[20, 17].GetEdge(0, Action.Right).NextTile = map2[21, 17];

        for (int x = 0xd; x <= 0x12; x++)
        {
            for (int y = 0x10; y <= 0x11; y++)
            {
                map1[x, y].RemoveEdge(0, Action.A);
                map1[x, y].RemoveEdge(0, Action.Down);
            }
        }

        for (int x = 0xd; x <= 0x12; x++)
        {
            for (int y = 0x10; y <= 0x11; y++)
            {
                map1[x, y].RemoveEdge(0, Action.A);
                map1[x, y].RemoveEdge(0, Action.Down);
            }
        }

        for (int x = 0x11; x <= 0x17; x++)
        {
            map2[x, 0x1f].RemoveEdge(0, Action.A);
        }

        IGTResults initialState = Yellow.IGTCheckParallel(gbs, new RbyIntroSequence(), 60);

        StreamWriter writer = new StreamWriter("moon.txt");

        writer.AutoFlush = true;

        DFParameters <Yellow, RbyMap, RbyTile> parameters = new DFParameters <Yellow, RbyMap, RbyTile>()
        {
            PruneAlreadySeenStates = true,
            MaxCost       = 20,
            NoEncounterSS = 60,
            RNGSS         = 56,
            EndTiles      = new RbyTile[] { map2[12, 9], },
            FoundCallback = state => writer.WriteLine(state.Log),
            EndEdgeSet    = 0,
        };

        DepthFirstSearch.StartSearch(gbs, parameters, gb.Tile, 0, initialState);
    }
Esempio n. 10
0
        internal void Demo80()
        {
            MultiThread mtLanceur = new MultiThread();

            mtLanceur.Lancer();
            do
            {
            } while (Console.ReadLine() != "0");
        }
Esempio n. 11
0
    public static IGTResults IGTCheckParallel <Gb>(Gb[] gbs, RbyIntroSequence intro, int numIgts, Func <GameBoy, bool> fn = null, int ss = 0, int ssOverwrite = -1) where Gb : Rby
    {
        intro.ExecuteUntilIGT(gbs[0]);
        byte[]   igtState = gbs[0].SaveState();
        byte[][] states   = new byte[numIgts][];
        MultiThread.For(numIgts, gbs, (gb, i) => {
            states[i] = gb.MakeIGTState(intro, igtState, i);
        });

        return(IGTCheckParallel(gbs, states, fn, ss, ssOverwrite));
    }
Esempio n. 12
0
    public static IGTResults IGTCheckParallel <Gb>(Gb[] gbs, int timesec, GscIntroSequence intro, int numIgts, Func <Gb, bool> fn = null, int ss = 0, int igtOffset = 0) where Gb : Gsc
    {
        gbs[0].SetTimeSec(timesec);
        intro.ExecuteUntilIGT(gbs[0]);
        byte[]     igtState    = gbs[0].SaveState();
        IGTResults introStates = new IGTResults(numIgts);

        MultiThread.For(numIgts, gbs, (gb, i) => {
            introStates[i] = gb.MakeIGTState(intro, igtState, i + igtOffset);
        });

        return(IGTCheckParallel(gbs, introStates, x => fn == null || fn((Gb)x), ss));
    }
Esempio n. 13
0
        public List <Worksheet> getVisualWS(out int hwndOfExcel)
        {
            List <Worksheet> wSList = new List <Worksheet>();
            ApplicationClass app    = new ApplicationClass();

            this._hwndOfExcel = app.Hwnd;
            app.Visible       = false;
            Workbook wBook = null;

            try
            {
                MultiThread.dowork("Microsoft Office Excel");
                wBook       = app.Workbooks.Open(_xlsFilePath, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing);
                hwndOfExcel = app.Hwnd;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
                if (wBook != null)
                {
                    wBook.Close(true, _xlsFilePath, Type.Missing);
                }
                //退出excel
                app.Quit();
                //释放资源
                if (wBook != null)
                {
                    System.Runtime.InteropServices.Marshal.ReleaseComObject(wBook);
                }
                System.Runtime.InteropServices.Marshal.ReleaseComObject(app);
                //调用GC的垃圾回收方法
                GC.Collect();
                GC.WaitForPendingFinalizers();
                hwndOfExcel = 0;
                return(wSList);
            }


            int       count = wBook.Sheets.Count;
            Worksheet sheet = null;

            for (int i = 1; i <= count; i++)
            {
                sheet = (Worksheet)wBook.Sheets[i];
                if (sheet.Visible == XlSheetVisibility.xlSheetVisible)  //如果可见,没有隐藏
                {
                    wSList.Add(sheet);
                }
            }
            return(wSList);
        }
Esempio n. 14
0
        public static short[] RescaleGrayscale(short[] input, int inputWidth, int inputHeight, int outputWidth, int outputHeight)
        {
            short[] output = new short[outputWidth * outputHeight];

            double xF = (double)inputWidth / (double)outputWidth;
            double yF = (double)inputHeight / (double)outputHeight;

            int xMax = inputWidth - 1;
            int yMax = inputHeight - 1;

            unchecked
            {
                MultiThread.For(0, outputHeight, y =>
                {
                    double oy0 = y * yF;
                    int oy1    = (int)oy0; // rounds down
                    int oy2    = (oy1 == yMax) ? oy1 : oy1 + 1;

                    double dy1 = oy0 - oy1;
                    double dy2 = 1.0 - dy1;

                    int yo0 = outputWidth * y;
                    int yo1 = inputWidth * oy1;
                    int yo2 = inputWidth * oy2;

                    double ox0, dx1, dx2;
                    int ox1, ox2;

                    for (int x = 0; x < outputWidth; x++)
                    {
                        ox0 = x * xF;
                        ox1 = (int)ox0;
                        ox2 = (ox1 == xMax) ? ox1 : ox1 + 1;

                        dx1 = ox0 - ox1;
                        dx2 = 1.0 - dx1;

                        output[yo0 + x] =
                            (short)((dy2 * ((dx2 * input[yo1 + ox1]) + (dx1 * input[yo1 + ox2]))) +
                                    (dy1 * ((dx2 * input[yo2 + ox1]) + (dx1 * input[yo2 + ox2]))));
                    }
                });
            }

            return(output);
        }
Esempio n. 15
0
 public override string ToString()
 {
     return($"{{Input={Url}, {nameof(UseTvApi)}={UseTvApi.ToString()}, " +
            $"{nameof(OnlyHevc)}={OnlyHevc.ToString()}, " +
            $"{nameof(OnlyShowInfo)}={OnlyShowInfo.ToString()}, " +
            $"{nameof(Interactive)}={Interactive.ToString()}, " +
            $"{nameof(HideStreams)}={HideStreams.ToString()}, " +
            $"{nameof(ShowAll)}={ShowAll.ToString()}, " +
            $"{nameof(UseAria2c)}={UseAria2c.ToString()}, " +
            $"{nameof(MultiThread)}={MultiThread.ToString()}, " +
            $"{nameof(VideoOnly)}={VideoOnly.ToString()}, " +
            $"{nameof(AudioOnly)}={AudioOnly.ToString()}, " +
            $"{nameof(Debug)}={Debug.ToString()}, " +
            $"{nameof(SelectPage)}={SelectPage}, " +
            $"{nameof(Cookie)}={Cookie}, " +
            $"{nameof(AccessToken)}={AccessToken}}}");
 }
Esempio n. 16
0
 public void Render(ILUT lut, int[] output)
 {
     if (lut == null)
     {
         MultiThread.For(0, Height, delegate(int y) {
             for (int i = Width * y, e = i + Width; i < e; i++)
             {
                 output[i] = _data[i];
             }
         });
     }
     else
     {
         MultiThread.For(0, Height, delegate(int y) {
             for (int i = Width * y, e = i + Width; i < e; i++)
             {
                 output[i] = lut[_data[i]];
             }
         });
     }
 }
Esempio n. 17
0
 public void Render(ILUT lut, int[] output)
 {
     if (lut == null)
     {
         MultiThread.For(0, Height, delegate(int y) {
             for (int i = Width * y, e = i + Width, p = i * 3; i < e; i++)
             {
                 output[i] = (_data[p++] << 16) | (_data[p++] << 8) | _data[p++];
             }
         });
     }
     else
     {
         MultiThread.For(0, Height, delegate(int y) {
             for (int i = Width * y, e = i + Width, p = i * 3; i < e; i++)
             {
                 output[i] = (lut[_data[p++]] << 16) | (lut[_data[p++]] << 8) | lut[_data[p++]];
             }
         });
     }
 }
        // transformation of x[n][m] to an array of binary numbers A[n][m][kol]
        public static void Z_D(int[, ,] A, int kol, int n, int m, double[,] koord, double eps)
        {
            int total_min = 0;
            int total_len = n;

            MultiThread.RunThreads(total_len,
                                   (threadIndex, threadCount) =>
            {
                int len      = total_len / threadCount;
                int lowBound = total_min + len * threadIndex;
                int hiBound  = (threadIndex == threadCount - 1) ? total_len : lowBound + len;
                for (int i = lowBound; i < hiBound; i++)
                {
                    for (int j = 0; j < m; j++)
                    {
                        int b;
                        b      = (int)(koord[i, j] / eps);
                        int b1 = ToGrey(b);     //b1 - Grey version of b
                        Zz_d(b1, i, j, A, kol); //Grey->binary
                    }
                }
            });
        }
 private void button2_Click(object sender, EventArgs e)
 {
     MultiThread.SpitResults();
 }
Esempio n. 20
0
 public static ConcurrentBag <RandomPathResult> StartSearch <Gb, T>(int numThreads, RandomSearchParameters <T> parameters) where Gb : GameBoy
     where T : Tile <T>
 {
     return(StartSearch(MultiThread.MakeThreads <Gb>(numThreads), parameters));
 }
Esempio n. 21
0
 public static void EndSearch(int numThreads, int delay, string path, int ss)
 {
     Gold[]   gbs           = MultiThread.MakeThreads <Gold>(numThreads);
     byte[][] initialStates = Gsc.IGTCheckParallel(gbs, 120, new GscIntroSequence(delay, GscStrat.GfSkip, GscStrat.TitleSkip, GscStrat.Continue), 60, gb => gb.Execute(path) == gb.OverworldLoopAddress).States;
     R29(gbs, initialStates, r29[38, 16]);
 }
Esempio n. 22
0
 public static IGTResults IGTCheckParallel <Gb>(int numThreads, RbyIntroSequence intro, int numIgts, Func <GameBoy, bool> fn = null, int ss = 0, int ssOverwrite = -1) where Gb : Rby
 {
     return(IGTCheckParallel(MultiThread.MakeThreads <Gb>(numThreads), intro, numIgts, fn, ss, ssOverwrite));
 }
Esempio n. 23
0
 public static IGTResults IGTCheckParallel <Gb>(int numThreads, int timesec, GscIntroSequence intro, int numIgts, Func <Gb, bool> fn = null, int ss = 0) where Gb : Gsc
 {
     return(IGTCheckParallel(MultiThread.MakeThreads <Gb>(numThreads), timesec, intro, numIgts, fn, ss));
 }