2016-12-19 1 views
0

안녕하세요. 내 프로그램이 항상 백그라운드에서 업데이트를 찾는 앱을 가질 수 있는지 궁금합니다. 앱 업데이트를 전달할 때 사용 가능한 업데이트가 있음을 알리는 알림이 약간 있습니다. 내 프로그램은 현재 프로그램이 시작될 때 메시지 상자가 있고 Java와 같은 작업 표시 줄에 아이콘을 갖고 싶기 때문에 잠시 기다려야한다는 메시지가 나타나면 잠시 기다려주십시오. # 업데이트 알림 메시지를 표시 하시겠습니까?

내가 notification

를 수행 할 작업의 그림이며,이 내가 업데이트를 확인하기 위해 현재 가지고있는 코드입니다.

public void CheckForUpdates() 
{ 
    try 
    { 
     CleanUp(); 

     WebClient downloadClient = new WebClient(); 
     downloadClient.DownloadFile(UpdateUrl, LocalUpdateFile); 
     downloadClient.Dispose(); 

     if (!File.Exists(LocalUpdateFile)) 
      throw new FileNotFoundException("The local update file is missing!", LocalUpdateFile); 

     UpdateSaveFile localFile = DecodeSaveFile(LocalUpdateFile); 

     Version localVersion = Assembly.GetEntryAssembly().GetName().Version; 
     Version onlineVersion = Version.Parse(localFile.VersionString); 

     if (onlineVersion > localVersion) 
     { 

      if (DevExpress.XtraEditors.XtraMessageBox.Show(String.Format("Version {0} available,\nInstall it now?", onlineVersion.ToString()), "Elfenliedtopfan5 BO3 Weapon Adder Updater.", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)//MessageBox.Show(String.Format("Version {0} available,\nInstall it now?", onlineVersion.ToString()), "Youtube Updater", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) 
      { 

       frmUpdater updateForm = new frmUpdater(localFile, GetPath(UpdateUrl)); 
       updateForm.ShowDialog(); 
      } 
     } 
     else 
     { 
      Message_elf msg = new Message_elf("You already have the latest version!", "elfenliedtopfan5 weapon adder 2016"); 
      //MessageBox.Show("You already have the latest version!", "Youtube Updater", MessageBoxButtons.OK, MessageBoxIcon.Information); 
     } 
    } 
    catch (Exception e) 
    { 
     MessageBox.Show("Error checking for updates\ntry again later!\n\nError Message:" + e.Message, "Youtube Updater", MessageBoxButtons.OK, MessageBoxIcon.Error); 
    } 
} 

나는 이것을 내 메인 양식을 통해 호출 할 수 있습니다.

updater1.CheckForUpdates(); 

어떤 도움을 많이 받았다.

+0

이 항목을 검토 한 적이 있습니까? http://stackoverflow.com/questions/11027051/how-to-develop-a-program-that-runs-in-the-background-in-net? – vipersassassin

답변

0

서비스를 생성하고 백그라운드에서 항상 실행되도록하는 것보다 많은 회사가 현재 설치 프로세스 중에 작업 스케줄러 작업을 만드는 것입니다. 이 작업 스케줄러 프로세스는 매번 실행되고 업데이트를 확인하기 위해 실행 중일 때 나타나는이 유틸리티에 대한 작업 표시 줄 UI 구성 요소를 빌드 할 수 있으며 업데이트가있을 때 스크린 샷으로 "토스트 (toast)"알림을 표시합니다.

+0

그 좋은 생각처럼 들리 겠지만;) 문제는 내가 거기에 내가 어떻게 내가 그걸 할 수있는 위의 코드에 연결됩니다 문제가 유일한 update.cs 및 해당 CS에 양식 그래서 내가 어떻게 얻을 수 있는지 확실하지 않다 그 일을. – elfenliedtopfan5

+0

앱이 실행될 때 앱에 인수를 전달하고, 해당 인수를 확인하고, 업데이트 호출 인 경우 UI가 작업 표시 줄에만 표시되고 업데이트가 수신되면 토스트 만 표시 할 수 있습니다. myapp.exe -update – pizzaslice

+0

mmmm 작동이 가능한 가장 좋은 방법은 찾기가 쉽지만 약간의 녹슨 느낌이 들기는하지만 오랜 시간이 걸렸습니다. – elfenliedtopfan5

관련 문제