모바일 오유 바로가기
http://m.todayhumor.co.kr
분류 게시판
베스트
  • 베스트오브베스트
  • 베스트
  • 오늘의베스트
  • 유머
  • 유머자료
  • 유머글
  • 이야기
  • 자유
  • 고민
  • 연애
  • 결혼생활
  • 좋은글
  • 자랑
  • 공포
  • 멘붕
  • 사이다
  • 군대
  • 밀리터리
  • 미스터리
  • 술한잔
  • 오늘있잖아요
  • 투표인증
  • 새해
  • 이슈
  • 시사
  • 시사아카이브
  • 사회면
  • 사건사고
  • 생활
  • 패션
  • 패션착샷
  • 아동패션착샷
  • 뷰티
  • 인테리어
  • DIY
  • 요리
  • 커피&차
  • 육아
  • 법률
  • 동물
  • 지식
  • 취업정보
  • 식물
  • 다이어트
  • 의료
  • 영어
  • 맛집
  • 추천사이트
  • 해외직구
  • 취미
  • 사진
  • 사진강좌
  • 카메라
  • 만화
  • 애니메이션
  • 포니
  • 자전거
  • 자동차
  • 여행
  • 바이크
  • 민물낚시
  • 바다낚시
  • 장난감
  • 그림판
  • 학술
  • 경제
  • 역사
  • 예술
  • 과학
  • 철학
  • 심리학
  • 방송연예
  • 연예
  • 음악
  • 음악찾기
  • 악기
  • 음향기기
  • 영화
  • 다큐멘터리
  • 국내드라마
  • 해외드라마
  • 예능
  • 팟케스트
  • 방송프로그램
  • 무한도전
  • 더지니어스
  • 개그콘서트
  • 런닝맨
  • 나가수
  • 디지털
  • 컴퓨터
  • 프로그래머
  • IT
  • 안티바이러스
  • 애플
  • 안드로이드
  • 스마트폰
  • 윈도우폰
  • 심비안
  • 스포츠
  • 스포츠
  • 축구
  • 야구
  • 농구
  • 바둑
  • 야구팀
  • 삼성
  • 두산
  • NC
  • 넥센
  • 한화
  • SK
  • 기아
  • 롯데
  • LG
  • KT
  • 메이저리그
  • 일본프로야구리그
  • 게임1
  • 플래시게임
  • 게임토론방
  • 엑스박스
  • 플레이스테이션
  • 닌텐도
  • 모바일게임
  • 게임2
  • 던전앤파이터
  • 마비노기
  • 마비노기영웅전
  • 하스스톤
  • 히어로즈오브더스톰
  • gta5
  • 디아블로
  • 디아블로2
  • 피파온라인2
  • 피파온라인3
  • 워크래프트
  • 월드오브워크래프트
  • 밀리언아서
  • 월드오브탱크
  • 블레이드앤소울
  • 검은사막
  • 스타크래프트
  • 스타크래프트2
  • 베틀필드3
  • 마인크래프트
  • 데이즈
  • 문명
  • 서든어택
  • 테라
  • 아이온
  • 심시티5
  • 프리스타일풋볼
  • 스페셜포스
  • 사이퍼즈
  • 도타2
  • 메이플스토리1
  • 메이플스토리2
  • 오버워치
  • 오버워치그룹모집
  • 포켓몬고
  • 파이널판타지14
  • 배틀그라운드
  • 기타
  • 종교
  • 단어장
  • 자료창고
  • 운영
  • 공지사항
  • 오유운영
  • 게시판신청
  • 보류
  • 임시게시판
  • 메르스
  • 세월호
  • 원전사고
  • 2016리오올림픽
  • 2018평창올림픽
  • 코로나19
  • 2020도쿄올림픽
  • 게시판찾기
  • 게시물ID : programmer_17558
    작성자 : 토왕
    추천 : 0
    조회수 : 1759
    IP : 122.44.***.185
    댓글 : 2개
    등록시간 : 2016/06/09 21:21:15
    http://todayhumor.com/?programmer_17558 모바일
    c# 로또 번호 생성기 소스인데..궁금증이있습니다
    옵션
    • 본인삭제금지
    using System;
    using System.Collections.Generic;
    using System.Collections;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Text;
    using System.Windows.Forms;
    using System.Threading;

    using System.Resources;
    using System.Reflection;
    using System.IO;

    namespace Lotto
    {
    public partial class Form1 : Form
    {
    ArrayList al;
    bool isStarted = false;

    private delegate void LabelView1(Label label, string message1);
    private delegate void TextBoxView1(TextBox textBox, string message1);

    public Form1()
    {
    InitializeComponent();

    return;
    }
    private void button1_Click(object sender, EventArgs e)
    {
    if (!this.isStarted)
    {
                    pictureBox1.Image = new Bitmap(Assembly.GetExecutingAssembly().GetManifestResourceStream("Lotto.blank.gif"));
                    pictureBox2.Image = new Bitmap(Assembly.GetExecutingAssembly().GetManifestResourceStream("Lotto.blank.gif"));
                    pictureBox3.Image = new Bitmap(Assembly.GetExecutingAssembly().GetManifestResourceStream("Lotto.blank.gif"));
                    pictureBox4.Image = new Bitmap(Assembly.GetExecutingAssembly().GetManifestResourceStream("Lotto.blank.gif"));
                    pictureBox5.Image = new Bitmap(Assembly.GetExecutingAssembly().GetManifestResourceStream("Lotto.blank.gif"));
                    pictureBox6.Image = new Bitmap(Assembly.GetExecutingAssembly().GetManifestResourceStream("Lotto.blank.gif"));

                    this.label2.Text = "";
                    this.label3.Text = "";
                    Thread work = new Thread(doWork);
                    work.Start();

    }
    }

    public void doWork()
    {



    this.isStarted = true;
    al = new ArrayList();
    Random rd = new Random(DateTime.Now.Millisecond);
    for (int i = 0; i < 6; i++)
    {
    MakeNum(i, rd);
    Thread.Sleep(200);
    }

    al.Sort();
    for (int j = 0; j < al.Count; j++)
    {
                    if (j == 0)
                        pictureBox1.Image = new Bitmap(Assembly.GetExecutingAssembly().GetManifestResourceStream("Lotto.ball" + al[j].ToString() + ".gif"));
                    if (j == 1)
                        pictureBox2.Image = new Bitmap(Assembly.GetExecutingAssembly().GetManifestResourceStream("Lotto.ball" + al[j].ToString() + ".gif"));
                    if (j == 2)
                        pictureBox3.Image = new Bitmap(Assembly.GetExecutingAssembly().GetManifestResourceStream("Lotto.ball" + al[j].ToString() + ".gif"));

                    if (j == 3)
                        pictureBox4.Image = new Bitmap(Assembly.GetExecutingAssembly().GetManifestResourceStream("Lotto.ball" + al[j].ToString() + ".gif"));
                    if (j == 4)
                        pictureBox5.Image = new Bitmap(Assembly.GetExecutingAssembly().GetManifestResourceStream("Lotto.ball" + al[j].ToString() + ".gif"));
                    if (j == 5)
                        pictureBox6.Image = new Bitmap(Assembly.GetExecutingAssembly().GetManifestResourceStream("Lotto.ball" + al[j].ToString() + ".gif"));
                }
    this.Invoke(new LabelView1(SetMessage), this.label1, "안상훈대박!!");
    this.isStarted = false;
    }

    public void MakeNum(int i, Random rd)
    {
    while (true)
    {
    int n = rd.Next(1, 45);
    if (!isNumExists(n))
    {
    al.Add(n);
    int iv = 400;

    for (int j = 1; j <= n; j++)
    {
                            if (i == 0)
                                pictureBox1.Image = new Bitmap(Assembly.GetExecutingAssembly().GetManifestResourceStream("Lotto.ball" + j + ".gif"));
                            if (i == 1)
                                pictureBox2.Image = new Bitmap(Assembly.GetExecutingAssembly().GetManifestResourceStream("Lotto.ball" + j + ".gif"));
                            if (i == 2)
                                pictureBox3.Image = new Bitmap(Assembly.GetExecutingAssembly().GetManifestResourceStream("Lotto.ball" + j + ".gif"));
                            if (i == 3)
    pictureBox4.Image = new Bitmap(Assembly.GetExecutingAssembly().GetManifestResourceStream("Lotto.ball" + j + ".gif"));
    if (i == 4)
    pictureBox5.Image = new Bitmap(Assembly.GetExecutingAssembly().GetManifestResourceStream("Lotto.ball" + j + ".gif"));
    if (i == 5)
    pictureBox6.Image = new Bitmap(Assembly.GetExecutingAssembly().GetManifestResourceStream("Lotto.ball" + j + ".gif"));
    Thread.Sleep(iv/n);
    }
    break;
    }
    //this.Invoke(new LabelView1(SetMessageAll), this.label2, i.ToString() +": 중복발생 [" + n + "], 다시 시도\r\n");
    }
    }
    public bool isNumExists(int num)
    {
    for (int j = 0; j < this.al.Count; j++)
    {
    if (this.al[j].Equals(num))
    return true;
    }
    return false;
    }

    private void SetMessage(Label label, string message)
    {
    label.Text  = ""+message+"";
    }

    private void SetMessageAll(Label label, string message)
    {
    label.Text += "" + message + "";
    }

    private void SetMessageBlank(Label label, string message)
    {
    label.Text = "" + message + "";
    }

    private void SetTextBoxAll(TextBox textBox, string message)
    {
    textBox.Text += "" + message + "";
    }

    private void Form1_Load(object sender, EventArgs e)
    {


    //this.ClientSize = new Size(image.Width, image.Height);
    //pictureBox1.Image = image;
    /*
    PictureBox pb = new PictureBox();
    pb.Image = image;
    pb.Dock = DockStyle.Fill;
     
    this.Controls.Add(pb);
    */
    /*

    System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(Form1));

    this.pictureBox1.Image = (System.Drawing.Image)(resources.GetObject("ball1.gif"));
    this.pictureBox1.Name = "pictureBox1";
    //pictureBox1.Image = imgNumber;
    */
    }

    }
    }

    이게 디자이너 폼이 하나 더 있긴 한데 여기서
     

    ArrayList al;
    bool isStarted = false;
     쓰래드를 무슨 용도로 쓴것인지 궁금합니다 .. 
    혹시나 아시는분 계신지요 ? ㅠ


    이 게시물을 추천한 분들의 목록입니다.
    푸르딩딩:추천수 3이상 댓글은 배경색이 바뀝니다.
    (단,비공감수가 추천수의 1/3 초과시 해당없음)

    죄송합니다. 댓글 작성은 회원만 가능합니다.

    번호 제 목 이름 날짜 조회 추천
    17561
    정규분포 엑셀 질문좀요! 베스트금지본인삭제금지 노찌루찌루 16/06/10 00:39 411 0
    17560
    매트랩에서 comm.TurboDecoder 이 기능 써보신 분 계신가요? 인생뭐 16/06/09 23:30 410 0
    17559
    엄청 기초적인 c언어 질문합니다! [7] 바닐라황혼 16/06/09 21:32 558 0
    c# 로또 번호 생성기 소스인데..궁금증이있습니다 [2] 본인삭제금지 토왕 16/06/09 21:21 1760 0
    17557
    울트라 에디트 정규식 질문.... [3] 본인삭제금지 구라쌔리냐 16/06/09 20:09 628 0
    17556
    main.cpp에 함수들이 많아져간다면..? [7] 본인삭제금지 창천을꿈꾸며 16/06/09 19:42 370 1
    17555
    css 선택자 관련질문입니다 [4] 본인삭제금지 calculus6E 16/06/09 19:27 341 0
    17550
    32비트 버전 안맞는 드라이버를 64비트를 강제로 쓸수 있는 방법은없나요 [5] 입업벤치 16/06/09 16:52 755 0
    17549
    Db질문좀해도될까요? [12] 본인삭제금지 3o 16/06/09 15:33 412 0
    17548
    서버에 있는 데이터를 사용해보고 싶습니다. [1] 니콜캣우먼 16/06/09 15:30 333 0
    17547
    메모리 엑세스 오류.. 도움이 필요합니다. [15] 베스트금지베오베금지본인삭제금지외부펌금지 푸아 16/06/09 13:29 7477 0
    17546
    해외 서버 질문드려요 ㅜㅜ 많이 찾아봐도 없더라고요 해외 서버를 두고 [1] 철판냄비 16/06/09 11:48 284 0
    17545
    오토마타 이론서 추천 부탁 드립니다. [3] 빠른물 16/06/09 09:12 1467 0
    17543
    Mastering Programming(KENT BECK) [1] 잉어 16/06/09 02:53 719 1
    17542
    c언어 질문드립니다 [4] 본인삭제금지 시이나마시롱 16/06/09 02:29 426 0
    17541
    C 언어 질문.. [4] 본인삭제금지 적녹색약 16/06/09 01:40 400 0
    17540
    취업하고싶다. 블루♪레이븐 16/06/08 23:21 507 2
    17539
    c언어 비주얼 스튜디오 사용중 질문입니다 [2] 본인삭제금지 적녹색약 16/06/08 22:17 476 0
    17538
    C++ 지뢰찾기 문의드립니다. [5] 본인삭제금지 대★맛이야 16/06/08 19:16 1251 0
    17537
    유니티 쉐이더 질문있습니다. [7] 본인삭제금지 초보오유러 16/06/08 18:33 473 0
    17535
    c++갤러그 소스분석중인데.. [4] 본인삭제금지 토왕 16/06/08 16:45 3652 0
    17534
    vcruntime140.dll 때문에 죽고싶습니다 ㅜㅜ [9] 다꿈이되길바람 16/06/08 16:29 1381 0
    17533
    sql에서 테이블에 있는 값 리턴은 어떻게 하나요? [3] 베스트금지베오베금지본인삭제금지외부펌금지 lihirt 16/06/08 14:01 427 0
    17532
    python 코드 메모리가 초과해서 전부 못돌리는거 같은데 도움요청이요ㅠ [10] 베스트금지본인삭제금지외부펌금지 뭉뭉이아빠 16/06/08 11:12 9273 0
    17531
    [본삭금] c#에서도 static 사용을 자제해야하나요? [14] 본인삭제금지 사이몬S 16/06/08 09:23 776 0
    17530
    C++ 질문드립니다. [2] SherryBirkin 16/06/08 02:44 398 0
    17529
    DB 관련 업종은 무슨 언어를 다루나오? [3] 본인삭제금지 훗날닭집사장 16/06/08 02:10 540 0
    17528
    행님들... [2] 플라라 16/06/07 23:52 262 0
    17527
    질문) 안드로이드 루트 권한 최초 등록시에만 su실행 됩니다 ㅠㅠ [2] 본인삭제금지 빙티 16/06/07 22:28 689 0
    17526
    안드로이드 어레이어댑터 체크박스 전체선택 [6] 본인삭제금지 민중의분노 16/06/07 21:20 2100 0
    [◀이전10개] [151] [152] [153] [154] [155] [156] [157] [158] [159] [160] [다음10개▶]
    단축키 운영진에게 바란다(삭제요청/제안) 운영게 게시판신청 자료창고 보류 개인정보취급방침 청소년보호정책 모바일홈