UWP 응용 프로그램 (SideLoaded에만 해당) 직렬 포트로 모니터링 응용 프로그램을 개발했습니다.ExtendedExecutionForegroundSession : UWP :: 내가 당황했습니다
예. 나는 직렬 포트를 통해 센서로부터 온도를 읽었다. 365 일 24 시간 모니터를 원합니다. 응용 프로그램은 항상 작동해야합니다. 정지 불가.
(6) 개발을위한 달
, 나는 소비 6 개월 .. 하지만 최소화 할 때 내 응용 프로그램이 중지이었다. 와우. 정말 ? 나는 공포에 질 렸습니다 .... 당신의 도움이 필요합니다.
디버깅 모드에서 모두 정상적으로 작동합니다. 최소화 된 경우에도 모든 백그라운드 작업은 작업을 중지하지 않고 기다리고 있습니다. 하지만 릴리스 모드 = 사이드로드 된 응용 프로그램이 중지되었습니다. 특히 장치 읽기/쓰기.
나는 이것을 피하기 위해 아래 코드를 추가했습니다. 그러나 이것은 문제를 해결하지 못했습니다.
// This is Caliburn.micro , UWP framework.
protected override async void OnLaunched(LaunchActivatedEventArgs e)
{
var newSession = new ExtendedExecutionForegroundSession();
newSession.Reason = ExtendedExecutionForegroundReason.Unconstrained;
newSession.Description = "Long Running Processing";
newSession.Revoked += SessionRevoked;
var result = await newSession.RequestExtensionAsync();
switch (result)
{
case ExtendedExecutionForegroundResult.Allowed:
Debug.WriteLine($"ExtendedExecutionForegroundResult.Allowed");
break;
default:
case ExtendedExecutionForegroundResult.Denied:
Debug.WriteLine($"ExtendedExecutionForegroundResult.Denied");
break;
}
private void SessionRevoked(object sender, ExtendedExecutionForegroundRevokedEventArgs args)
{
Debug.WriteLine($"ExtendedExecutionForegroundResult :: SessionRevoked");
}
및 package.appxmanifest가 있습니다.
<?xml version="1.0" encoding="utf-8"?>
<Package xmlns="http://schemas.microsoft.com/appx/manifest/foundation/windows10"
xmlns:mp="http://schemas.microsoft.com/appx/2014/phone/manifest"
xmlns:uap="http://schemas.microsoft.com/appx/manifest/uap/windows10"
xmlns:rescap="http://schemas.microsoft.com/appx/manifest/foundation/windows10/restrictedcapabilities"
xmlns:desktop="http://schemas.microsoft.com/appx/manifest/desktop/windows10"
IgnorableNamespaces="uap mp rescap">
.....
<Capabilities>
<Capability Name="internetClient" />
<rescap:Capability Name="extendedBackgroundTaskTime"/>
<rescap:Capability Name="extendedExecutionUnconstrained"/>
<DeviceCapability Name="serialcommunication">
<Device Id="any">
<Function Type="name:serialPort" />
</Device>
</DeviceCapability>
</Capabilities>
</Package>
다음은 다른 정보입니다.
- 모든 컴파일 및 빌드가 성공적입니다.
- 디버그 모드에서 모든 작업 (백그라운드 대기 중)이 작동합니다. 멈추지 마라.
- 출력 됨 사이드로드 된 응용 프로그램으로, 그것은 (비주얼 스튜디오에) 릴리스 모드에서
- ... "최소화"동안 작동하지 않습니다. 멈추지 않습니다.
- AC 전원이있는 데스크탑 (노트북 PC). 배터리가 아님.
- Windows 10 설정. "백그라운드 앱"= 설치된 내 보류 응용 프로그램에 대해 켜짐 (확인 됨).
도와주세요!
업데이트를 1 :
나는이 같은 code..but 사용했습니다. 작동하지 않음 ...
var extendedExecutionSession = new ExtendedExecutionSession();
extendedExecutionSession.Reason = ExtendedExecutionReason.Unspecified;
var extendedExecutionResult = await extendedExecutionSession.RequestExtensionAsync();
if (extendedExecutionResult != ExtendedExecutionResult.Allowed)
{
//extended execution session revoked
extendedExecutionSession.Dispose();
extendedExecutionSession = null;
}
어떤 것을 사용해야합니까? 수동 버튼 를 사용하여 VS에서이 상태로 전송 될 때까지
- ExtendedExecutionForegroundSession
- ExtendedExecutionSession는
확장 실행 세션을 사용하려고 할 때 정확히 실패한 점을 명확히 할 수 있습니까? (a) EE에 대한 요청이 거부 되었습니까? (b) 요청은 허용되지만 앱을 최소화하면 앱이 일시 중지됩니까? (c) 앱이 일시 중지되지 않지만 최소화 된 특정 API가 작동을 멈 춥니 다. (d) 다른 것? –
와우 .. 이제 Suspend를 시뮬레이트하는 기능을 배웠습니다! 일시 중단 후 오류 메시지가 표시 될 수 있습니다. 내 장치와 관련이 있습니다! 나는 문제를 해결할 수 있었다! 고맙습니다 . 주된 원인은 다음과 같습니다. 내 직렬 라이브러리에 SuspendEvent가 있습니다. 기기 연결이 종료되었습니다. 하하 .. 미안. 고맙습니다. –
다른 질문을 게시합니다 : https://stackoverflow.com/questions/47586768/uwp-suspend-disable-with-extendedexecutionsession-or-extendedexecutionforeground –