c# - Issue locking the phone before the camera is fully initialized. When I unlock the phone it breaks -


I am developing a camera app and when I leave the app before the camera starts completely, then I have a problem is coming and I tried my to have them back to OnNavigatedFrom in the pattern I have this:

  protected override void on Nevigetifom (Nevigeshniventarj e) {try {if (Kmranit) {Dispacrkbegininvonke (() = & gt; {if (job! = null) {Kamkdiskpose (); Kamkkpturecompleted - = Kam_kpturecompleted; Kamkkptureimjavailable - = Kam_kptureimjavailable; Kamkotofokskpleted - = cam_AutoFocusCompleted; CameraButtons.ShutterKeyPressed - = OnButtonFullPress; cam = null; cameraInit = false;}}); }} Hold (Exception Pre) {Message Box. Show (ex.Message); }}  

This I have OnNavigatedTo Method:

  protected override void OnNavigatedTo (System.Windows.Navigation.NavigationEventArgs E ) {// To check if the camera is available on the device. If (photochemera.iskmiera type support (camera type primary) == true) {if (cam == empty) {cam = new Microsoft.Devices.photoCamera (CameraType.Primary); // Create camera event handlers //// When the capture sequence is completed the event is removed. Cam.CaptureCompleted + = new event handler & lt; Camera operationwith all eventsource & gt; (Cam_CaptureCompleted); The //// event is removed when the capture sequence is completed and an image is available. Cam.CaptureImageAvailable + = New EventHeader & lt; Microsoft.Devices.ContentReadyEventArgs & gt; (Cam_CaptureImage available); The event has been removed when the //// event is focused. Cam.aututofocuscompleted + = New EventHandler & lt; Camera OperationInquire Event Event & gt; (Cam_AutoFocusCompleted); //// Shutter button gets removed when the full press is received. Cam.Initialized + = cam_Initialized; Camerabaton Shuttercoid + onbutton fullpress; } Set the video brush source on the //// camera. CanvasCamBrush.SetSource (CAM); }  

And this is my cam_initialized Method:

  zero Kam_inilaijhed (object sender, Kamraopreshnsnyojit Iventarj e) {if ( E) successful {cameraInit = true; If (cameraInit) {cam.FlashMode = FlashMode.off; }}}  

The main problem is that when onNavigatedFrom system is launched so the seam does not fully started and then OnNavigatedTo method when I take back to the app I onNavigatedFrom before running cam_initialized Law went out, unless there is no need to wait there .

Here is an example of another such person who had this problem but I could not work on it:

Thank you everyone, L

< / Div>

Before placing the camera completely before I leave the app, I have resolved to make it an "infinite loop". The OnNavigatedFrom code is that:

  Protected override minus renewForm (Navigation Event Event e) {try {while (CameraInit) {System.Threading.Thread.Sleep (100 ); } If (cameraInit) {Dispatcher.BeginInvoke ((=) => {if (cam! = Null) {cam.Dispose (); cam.CaptureCompleted - = cam_CaptureCompleted; cam.CaptureImageAvailable - = cam_CaptureImage is available; cam. AutoFocusCompleted - = cam_AutoFocusCompleted; CamBoots.ShutterCpress - = On ButtonFlopress; Cam = Blank; CameraPaint = False;}}); }} Hold (Exception Pre) {Message Box. Show (ex.Message); }}  

This is the best solution I can hope to help someone thanks to


Comments

Popular posts from this blog

java - Can't add JTree to JPanel of a JInternalFrame -

javascript - data.match(var) not working it seems -

javascript - How can I pause a jQuery .each() loop, while waiting for user input? -