Ejemplo n.º 1
0
        static async Task Main(string[] args)
        {
            // ***
            // *** An object that cannot be disposed.
            // ***
            object obj = new object();
            await obj.TryDisposeAsync();

            // ***
            // *** An object that can be disposed.
            // ***
            ISomeThing someThing = new SomeThing();
            await someThing.TryDisposeAsync();

#if (NET5_0 || NET6_0)
            // ***
            // *** An object that can be disposed.
            // ***
            ISomeAsyncThing someAsyncThing = new SomeAsyncThing();
            await someAsyncThing.TryDisposeAsync();
#endif

            // ***
            // *** Wrap the ITemporaryFolder in a using statement.
            // ***
            ITemporaryFolder tempFolder1 = TemporaryFolderFactory.Create1();

            using (ITryDisposable <ITemporaryFolder> disposableTempFolder = TryDisposableFactory.Create(tempFolder1))
            {
                string path = disposableTempFolder.Instance.Path;

                // ***
                // *** If tempFolder is disposable, it will get disposed, otherwise it will be ignored.
                // ***
            }

            // ***
            // *** Wrap the ITemporaryFolder in a using statement (non generic interface).
            // ***
            ITemporaryFolder tempFolder2 = TemporaryFolderFactory.Create2();

            using (ITryDisposable disposableTempFolder = TryDisposableFactory.Create(tempFolder2))
            {
                // ***
                // *** If tempFolder is disposable, it will get disposed, otherwise it will be ignored.
                // ***
            }
        }
Ejemplo n.º 2
0
        static void Main(string[] args)
        {
            bool tmpR = Boolean.Parse("TRUE");


            for (int i = 0; i < 100; i++)
            {
                Console.WriteLine("AAAAA {0}", i);
                ProcessSSS();
            }

            SomeThing s = null;

            Console.WriteLine("SSSSSSSSSSS");
            Console.WriteLine("SSS".Equals(s?.someVal) ? "!!!!!" : "?????");
            Console.WriteLine("SSSSSSSSSSS");

            int kk = Convert.ToInt32("");


            Console.ReadLine();
        }