C#의 Windows 7 Panasonic Toughbook (Tablet)에서 사용할 Windows Form 실행기/업데이트/스플래시 화면 응용 프로그램을 개발 중입니다. 런처는 내 바탕 화면과 내 Toughbooks 중 하나에서 잘 작동하지만 ... "실제 환경"장치를 테스트하는 데는 첫 출시 이후에도 양식을 표시하는 데 20 초 이상 걸립니다. (양식이 표시되면 앱이 작동하는 방식과 같이 빠르게 진행됩니다.) 설치 후 장치를 처음 실행하는 것은 빠르지 만 처음 시작한 후에는 시간이 오래 걸립니다.C# Windows Form을 영원히로드합니다.
USB를 통해 연결하거나 네트워크에 연결할 수 없기 때문에 테스트하는 방법을 모르겠습니다. 응용 프로그램이 파일을 열 것인지 여부는 중요하지 않습니다. 실제로 대부분의 경우, 앱이 열리고, 다른 업데이트를 확인하기에는 너무 빠르며, 기본 앱을 실행하고 자체를 종료합니다.
현재의 과정은 다음과 같습니다
생성자 :
public MyConstructor() { InitializeComponent(); }
양식로드 : 설명에서
private void Form1_Load(object sender, EventArgs e)
{
if (!isLoaded)
{
System.Configuration.ConfigurationFileMap fileMap = new ConfigurationFileMap("parentApplication.exe.config"); //Path to your config file
System.Configuration.Configuration configuration = System.Configuration.ConfigurationManager.OpenMappedMachineConfiguration(fileMap);
log4net.Config.XmlConfigurator.Configure();
WebRequest.url = configManager.AppSettings.Settings["SURL"].Value;
// Set a timer to run the update process momentarily to allow the UI thread to update and display. (UI must be idle to run Timer)
updateTimer = new System.Timers.Timer(1000);
updateTimer.Elapsed += new ElapsedEventHandler(beginUpdate);
updateTimer.Enabled = true;
isLoaded = true;
}
}
업데이트 프로세스
private void beginUpdate(Object sender, EventArgs e)
{
// If any of this fails, we still want to launch the main application.
try
{
// Prevent the timer from doing anything else.
updateTimer.Enabled = false;
string version = "0";
try
{
Version v = AssemblyName.GetAssemblyName("ParentApplication.exe").Version;
version = v.ToString();
}
catch
{
version = "0";
}
updateProgress(5);
DateTime buffer = DateTime.Now.AddMinutes(-5);
DateTime last = Convert.ToDateTime(configManager.AppSettings.Settings[lastCheck].Value);
int comp = DateTime.Compare(buffer, last);
if (comp < 0)
{
// Begin update process
updateApplication(version);
}
updateProgress(100);
System.Threading.Thread.Sleep(1000);
}
catch (Exception er)
{
logger.Error("Error in update application.", er);
}
// The updater can't update itself. Launch the external application
// to handle the updating of the updater. This application also launches
// the main executable.
Process sync = new Process();
sync.StartInfo.UseShellExecute = false;
sync.StartInfo.FileName = "FinishUpdate.exe";
sync.StartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
sync.StartInfo.Verb = "runas";
sync.Start();
Application.Exit();
}
20 초 동안 "매달리기"는 일종의 시간 초과와 비슷합니다. 장치가 네트워크에 없다고 언급했습니다. 네트워크 리소스를 열려고 시도하는 코드가 있습니까? updateApplication()은 네트워크를 통해 확인합니까? –
네트워크에 연결되지 않은 서버에 무선 카드를 통한 연결이 열립니다. 흥미로운 점은 양식이 20 초 동안 전혀 나타나지 않는다는 것입니다. 폼이 나타나면, 모든 것을 잘 처리합니다. – teynon
뭔가 (네트워크 호출과 같은) 메시지 큐를 차단하는 경우 양식이 20 초 동안 표시되지 않습니다. 한참 걸릴 수있는 일을한다면 별도의 스레드에서 수행하십시오 (BackgroundWorker는 일반적으로 WinForms 컨텍스트에서 잘 작동합니다). –