# HG changeset patch # User StephaneLenclud # Date 1441297128 -7200 # Node ID f6d93a560a78490a900269e19b4ca8e5c4dd254e # Parent 703daa997f596a4bd36e99ae07ccf26d36560b3e Open/Close optical drive tray toggle now working. diff -r 703daa997f59 -r f6d93a560a78 Server/MainForm.Hid.cs --- a/Server/MainForm.Hid.cs Wed Sep 02 22:35:47 2015 +0200 +++ b/Server/MainForm.Hid.cs Thu Sep 03 18:18:48 2015 +0200 @@ -336,9 +336,16 @@ if (PreventRemovalOfVolume(handle,false)) { - StorageCheckVerify(handle); + //StorageCheckVerify(handle); - if (MediaEject(handle)) + DateTime before; + before = DateTime.Now; + bool ejectSuccess = MediaEject(handle); + double ms = (DateTime.Now - before).TotalMilliseconds; + + //We assume that if it take more than a certain time to for eject to execute it means we actually ejected. + //If our eject completes too rapidly we assume the tray is already open and we will try to close it. + if (ejectSuccess && ms > 100) { Debug.WriteLine("Media was ejected"); }