본문 바로가기
KDT/C# 프로그래밍

23/07/27 데이터매니저 데이터로드

by 잰쟁 2023. 7. 27.
728x90

데이터매니저 클래스(싱글톤 사용)

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace starcraft
{
    public class DataManager
    {
        public Action loadComplete;

        //싱글톤 생성자
        public static readonly DataManager instance = new DataManager();

        public void LoadDatas()
        {
            Console.WriteLine("로드중...");
            Console.WriteLine("로드중...");
            Console.WriteLine("로드완료");

            this.loadComplete();
        }
    }
}

App 클래스

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Collections;
using starcraft;
using System.Data;

namespace starcraft
{
    public class App
    {

        //생성자
        public App()
        {
            DataManager.instance.loadComplete = () => {
                Console.WriteLine("데이터 로드 완료~!~!~!~");
            };

            //데이터매니저
            DataManager.instance.LoadDatas();

        }

    }
}

'KDT > C# 프로그래밍' 카테고리의 다른 글

23/07/27 대리자 연습  (0) 2023.07.27
23/07/27 Action 대리자  (0) 2023.07.27
23/07/27 람다  (0) 2023.07.27
23/07/27 대리자  (0) 2023.07.27
23/07/27 전시간 수업 내용 정리  (0) 2023.07.27