0
내 앱에서 바코드 스캔 기능이 있습니다. 기본 페이지에 바코드 버튼이 있습니다. 사용자는이를 클릭하고 바코드 스캔 페이지으로갑니다. 그것은 다시 이동할 때, 나는 그 말을 메시지 상자를 얻을 : 바코드 스캔보기에서 뒤로 이동할 때 인스턴스가 공유 리소스에 대해 처리됩니다.
This instance has been disposed. Possibly because another component required a shared resource.
은 내가
PhotoCamera
을 배치하고, 바코드 스캔 페이지의
OnNavigatedFrom
방법으로 모든 이벤트를 취소 만, 여전히 같은 일을 얻는다.
나는 코드에 들어갔다 및이 방법에 문제 발견 :
at Microsoft.Devices.Camera.InvokeAndRemapExceptions(Action a)
at Microsoft.Devices.PhotoCamera.get_IsFocusSupported()
at Microsoft.Devices.PhotoCamera.Focus()
at WP7.ScanBarCode.BarCode.cam_AutoFocusCompleted(Object sender, CameraOperationCompletedEventArgs e)
at Microsoft.Devices.Camera.<>c__DisplayClass21`1.<SafeFireEvent>b__1f(Object ignored)
at System.Threading.ThreadPool.WorkItem.WaitCallback_Context(Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadPool.WorkItem.doWork(Object o)
at System.Threading.Timer.ring()
어떤 아이디어 :
PhotoCamera _cam;
VideoBrush _videoBrush = new VideoBrush();
Stopwatch watch = new Stopwatch();
int _nbTry;
Result result = null;
void cam_AutoFocusCompleted(object sender, CameraOperationCompletedEventArgs e)
{
if (result == null)
{
try
{
_nbTry++;
watch.Reset();
watch.Start();
while ((result == null) && (watch.ElapsedMilliseconds < 1500) && _cam != null)
{
var binaryBitmap = GetBitmapFromVideo(_cam);
if (binaryBitmap != null)
{
try
{
result = BarCodeManager.ZXingReader.decode(binaryBitmap);
}
catch
{
// Wasn't able to find a barcode
}
}
}
if (result != null)
{
BarCodeManager._onBarCodeFound(result.Text);
}
else
{
if (_cam != null)
{
_cam.Focus();
}
}
}
catch (Exception exc)
{
BarCodeManager._onError(exc);
}
}
}
잡혀 다음과 같은 예외가 스택 트레이스가가요를? 감사!
에뮬레이터에서 메시지 상자가 표시되면 콜 스택을 끊어 붙여 넣을 수 있습니까? –
내 대답을보세요! – MAXE