The intention is to support more than one session at a time, showing in the sample how it's possible to be scanning in one session, while still transferring images in another.  While the idea was there, the implementation wasn't.  So I'm working on making m_twainlocalsession behave more like what I want.  Currently it's still just one session, but now it's created and destroyed as needed.  There's an m_twainlocalsessionInfo attribute, which may morph into a TwainLocalInfo object, as the cleanup continues.  Eventually m_twainlocalsession will become a list or an array that can be indexed (on the scanner side) with the sessionId. My current plan is to support a max of two sessions, just to prove the concept.

--- source/TwainDirectSupport/twainlocalscanner.cs
+++ source/TwainDirectSupport/twainlocalscanner.cs
@@ -120,7 +120,10 @@
             m_fConfirmScanScale = a_fConfirmScanScale;

             // Set up session specific content...
-            m_twainlocalsession = new TwainLocalSession(m_szXPrivetToken);
+            m_twainlocalsessionInfo = new TwainLocalSession("");
+
+            // Our lock...
+            m_objectLock = new object();

             // We use this to get notification about events...
             m_autoreseteventWaitForEvents = new AutoResetEvent(false);
@@ -170,13 +173,13 @@

             // Stock it...
             dnssddeviceinfo.szLinkLocal = "";
-            dnssddeviceinfo.szServiceName = m_twainlocalsession.DeviceRegisterGetTwainLocalInstanceName();
+            dnssddeviceinfo.szServiceName = m_twainlocalsessionInfo.DeviceRegisterGetTwainLocalInstanceName();
             dnssddeviceinfo.szTxtCs = "offline";
             dnssddeviceinfo.blTxtHttps = true;
             dnssddeviceinfo.szTxtId = "";
-            dnssddeviceinfo.szTxtNote = m_twainlocalsession.DeviceRegisterGetTwainLocalNote();
+            dnssddeviceinfo.szTxtNote = m_twainlocalsessionInfo.DeviceRegisterGetTwainLocalNote();
             dnssddeviceinfo.szTxtTxtvers = "1";
-            dnssddeviceinfo.szTxtTy = m_twainlocalsession.DeviceRegisterGetTwainLocalTy();
+            dnssddeviceinfo.szTxtTy = m_twainlocalsessionInfo.DeviceRegisterGetTwainLocalTy();
             dnssddeviceinfo.szTxtType = "twaindirect";

             // Return it...
@@ -189,7 +192,7 @@
         /// <returns>TWAIN Local ty= field</returns>
         public string GetTwainLocalTy()
         {
-            return (m_twainlocalsession.DeviceRegisterGetTwainLocalTy());
+            return (m_twainlocalsessionInfo.DeviceRegisterGetTwainLocalTy());
         }

         /// <summary>
@@ -339,7 +342,7 @@
                 "/privet/info",
                 "GET",
                 new string[] {
-                    "X-Privet-Token:"
+                    "X-Privet-Token: \"\""
                 },
                 null,
                 null,
@@ -518,12 +521,13 @@
             string szFunction = "ClientScannerCloseSession";

             // Lock this command to protect the session object...
-            lock (m_twainlocalsession)
+            lock (m_objectLock)
             {
                 // Skip the command if we've no session state or if we're already closed.
                 // But return true anyway, because one should never fail when trying to
                 // shut something down...
-                if (    (m_twainlocalsession.GetSessionState() == SessionState.noSession)
+                if (    (m_twainlocalsession == null)
+                    ||  (m_twainlocalsession.GetSessionState() == SessionState.noSession)
                     ||  (m_twainlocalsession.GetSessionState() == SessionState.closed))
                 {
                     Log.Error(szFunction + ": already closed");
@@ -593,8 +597,14 @@
             string szFunction = "ClientScannerCreateSession";

             // Lock this command to protect the session object...
-            lock (m_twainlocalsession)
-            {
+            lock (m_objectLock)
+            {
+                // Create it if we need it...
+                if (m_twainlocalsession == null)
+                {
+                    m_twainlocalsession = new TwainLocalSession(m_szXPrivetToken);
+                }
+
                 // Check our incoming state...
                 if (m_twainlocalsession.GetSessionState() != SessionState.noSession)
                 {
@@ -677,7 +687,7 @@
             string szFunction = "ClientScannerGetSession";

             // Lock this command to protect the session object...
-            lock (m_twainlocalsession)
+            lock (m_objectLock)
             {
                 // Check our state...
                 if (m_twainlocalsession.GetSessionState() == SessionState.noSession)
@@ -743,7 +753,7 @@
             string szFunction = "ClientScannerReadImageBlock";

             // Lock this command to protect the session object...
-            lock (m_twainlocalsession)
+            lock (m_objectLock)
             {
                 // Check our state...
                 if ((m_twainlocalsession.GetSessionState() != SessionState.capturing)
@@ -856,7 +866,7 @@
             string szFunction = "ClientScannerReadImageBlockMetadata";

             // Lock this command to protect the session object...
-            lock (m_twainlocalsession)
+            lock (m_objectLock)
             {
                 // Check our state...
                 if ((m_twainlocalsession.GetSessionState() != SessionState.capturing)
@@ -973,7 +983,7 @@
             string szFunction = "ClientScannerReleaseImageBlocks";

             // Lock this command to protect the session object...
-            lock (m_twainlocalsession)
+            lock (m_objectLock)
             {
                 // Check our state...
                 if (    (m_twainlocalsession.GetSessionState() != SessionState.capturing)
@@ -1050,7 +1060,7 @@
             string szFunction = "ClientScannerSendTask";

             // Lock this command to protect the session object...
-            lock (m_twainlocalsession)
+            lock (m_objectLock)
             {
                 // Check our state...
                 if (m_twainlocalsession.GetSessionState() != SessionState.ready)
@@ -1106,7 +1116,7 @@
             string szFunction = "ClientScannerStartCapturing";

             // Lock this command to protect the session object...
-            lock (m_twainlocalsession)
+            lock (m_objectLock)
             {
                 // Check our state...
                 if (m_twainlocalsession.GetSessionState() != SessionState.ready)
@@ -1161,7 +1171,7 @@
             string szFunction = "ClientScannerStopCapturing";

             // Lock this command to protect the session object...
-            lock (m_twainlocalsession)
+            lock (m_objectLock)
             {
                 // Check our state...
                 if (m_twainlocalsession.GetSessionState() != SessionState.capturing)
@@ -1216,7 +1226,7 @@
             string szFunction = "ClientScannerWaitForEvents";

             // Lock this command to protect the session object...
-            lock (m_twainlocalsession)
+            lock (m_objectLock)
             {
                 // Check our state...
                 if (m_twainlocalsession.GetSessionState() == SessionState.noSession)
@@ -1313,8 +1323,8 @@
                 return;
             }

-            // We found it, squirrel away the value...
-            szXPrivetToken = a_httplistenercontext.Request.Headers.Get(ii);
+            // We found it, squirrel away the value, remove any double quotes...
+            szXPrivetToken = a_httplistenercontext.Request.Headers.Get(ii).Replace("\"","");

             // Handle the info command...
             if (szUri == "/privet/info")
@@ -1373,7 +1383,7 @@

             // If we are running a session, make sure that the command's id matches
             // the session's id...
-            if (!string.IsNullOrEmpty(m_twainlocalsession.GetSessionId()))
+            if ((m_twainlocalsession != null) && !string.IsNullOrEmpty(m_twainlocalsession.GetSessionId()))
             {
                 if (jsonlookup.Get("params.sessionId") != m_twainlocalsession.GetSessionId())
                 {
@@ -1512,7 +1522,7 @@
         /// <returns>users friendly name</returns>
         public string GetTwainLocalNote()
         {
-            return (m_twainlocalsession.DeviceRegisterGetTwainLocalNote());
+            return (m_twainlocalsessionInfo.DeviceRegisterGetTwainLocalNote());
         }

         /// <summary>
@@ -1538,10 +1548,10 @@
             blSuccess = m_httpserver.ServerStart
             (
                 DeviceDispatchCommand,
-                m_twainlocalsession.DeviceRegisterGetTwainLocalInstanceName(),
+                m_twainlocalsessionInfo.DeviceRegisterGetTwainLocalInstanceName(),
                 iPort,
-                m_twainlocalsession.DeviceRegisterGetTwainLocalTy(),
-                m_twainlocalsession.DeviceRegisterGetTwainLocalNote()
+                m_twainlocalsessionInfo.DeviceRegisterGetTwainLocalTy(),
+                m_twainlocalsessionInfo.DeviceRegisterGetTwainLocalNote()
             );
             if (!blSuccess)
             {
@@ -1584,7 +1594,7 @@
             // We're being asked to clear the register...
             if (a_iScanner < 0)
             {
-                m_twainlocalsession.DeviceRegisterClear();
+                m_twainlocalsessionInfo.DeviceRegisterClear();
                 return (true);
             }

@@ -1603,7 +1613,7 @@
             // Get the device code...
             try
             {
-                m_twainlocalsession.DeviceRegisterSet
+                m_twainlocalsessionInfo.DeviceRegisterSet
                 (
                     szDeviceName,
                     szSerialNumber,
@@ -1627,7 +1637,7 @@
         public bool DeviceRegisterLoad()
         {
             // First load the data...
-            if (!m_twainlocalsession.DeviceRegisterLoad(this, Path.Combine(m_szWriteFolder, "register.txt")))
+            if (!m_twainlocalsessionInfo.DeviceRegisterLoad(this, Path.Combine(m_szWriteFolder, "register.txt")))
             {
                 return (false);
             }
@@ -1642,7 +1652,7 @@
         /// <returns>true on success</returns>
         public bool DeviceRegisterSave()
         {
-            return (m_twainlocalsession.DeviceRegisterSave(Path.Combine(m_szWriteFolder, "register.txt")));
+            return (m_twainlocalsessionInfo.DeviceRegisterSave(Path.Combine(m_szWriteFolder, "register.txt")));
         }

         #endregion
@@ -1760,6 +1770,13 @@
                     m_apicmdEvent.HttpAbort();
                     m_apicmdEvent = null;
                 }
+
+                // Lose the session...
+                if (m_twainlocalsession != null)
+                {
+                    m_twainlocalsession.Dispose();
+                    m_twainlocalsession = null;
+                }
             }
         }

@@ -1811,6 +1828,11 @@
                 {
                     m_twainlocalsession.Dispose();
                     m_twainlocalsession = null;
+                }
+                if (m_twainlocalsessionInfo != null)
+                {
+                    m_twainlocalsessionInfo.Dispose();
+                    m_twainlocalsessionInfo = null;
                 }
             }
         }
@@ -1947,7 +1969,7 @@
                             // The session object has been updated...
                             case "imageBlocks":
                                 Log.Verbose(szFunction + ": imageBlocks event...");
-                                lock (m_twainlocalsession)
+                                lock (m_objectLock)
                                 {
                                     // Check the session revision number...
                                     if (!int.TryParse(jsonlookup.Get(szEvent + ".session.revision", false), out iSessionRevision))
@@ -2254,7 +2276,7 @@
                 // Try to get any session data that may be in the payload, we
                 // need to lock this, since it could happen while we're in the
                 // midst of processing some other command...
-                lock (m_twainlocalsession)
+                lock (m_objectLock)
                 {
                     // Parse the data...
                     ParseSession(m_waitforeventsinfo.m_szReason, m_waitforeventsinfo.m_apicmd);
@@ -2372,14 +2394,21 @@
                 Dnssd.DnssdDeviceInfo dnssddeviceinfo = GetDnssdDeviceInfo();

                 // Device state...
-                switch (m_twainlocalsession.GetSessionState())
-                {
-                    default: szDeviceState = "stopped"; break;
-                    case SessionState.noSession: szDeviceState = "idle"; break;
-                    case SessionState.capturing: szDeviceState = "processing"; break;
-                    case SessionState.closed: szDeviceState = "processing"; break;
-                    case SessionState.draining: szDeviceState = "processing"; break;
-                    case SessionState.ready: szDeviceState = "processing"; break;
+                if (m_twainlocalsession == null)
+                {
+                    szDeviceState = "idle";
+                }
+                else
+                {
+                    switch (m_twainlocalsession.GetSessionState())
+                    {
+                        default: szDeviceState = "stopped"; break;
+                        case SessionState.noSession: szDeviceState = "idle"; break;
+                        case SessionState.capturing: szDeviceState = "processing"; break;
+                        case SessionState.closed: szDeviceState = "processing"; break;
+                        case SessionState.draining: szDeviceState = "processing"; break;
+                        case SessionState.ready: szDeviceState = "processing"; break;
+                    }
                 }

                 // If we don't have a timestamp, or if the timestamp has exceeded
@@ -2672,7 +2701,7 @@
             string szFunction = "DeviceInfo";

             // Reply to the command with a session object...
-            blSuccess = DeviceUpdateSession(szFunction, a_apicmd, false, null, m_twainlocalsession.GetSessionState(), -1, null);
+            blSuccess = DeviceUpdateSession(szFunction, a_apicmd, false, null, m_twainlocalsessionInfo.GetSessionState(), -1, null);
             if (!blSuccess)
             {
                 DeviceReturnError(szFunction, a_apicmd, "critical", null, -1);
@@ -2694,7 +2723,7 @@
             string szFunction = "DeviceScannerCloseSession";

             // Protect our stuff...
-            lock (m_twainlocalsession)
+            lock (m_objectLock)
             {
                 // State check...
                 switch (m_twainlocalsession.GetSessionState())
@@ -2806,8 +2835,15 @@
             string szFunction = "DeviceScannerCreateSession";

             // Protect our stuff...
-            lock (m_twainlocalsession)
-            {
+            lock (m_objectLock)
+            {
+                // Create it if we need it...
+                if (m_twainlocalsession == null)
+                {
+                    m_twainlocalsession = new TwainLocalSession(m_szXPrivetToken);
+                    m_twainlocalsession.DeviceRegisterLoad(this, Path.Combine(m_szWriteFolder, "register.txt"));
+                }
+
                 // Init stuff...
                 szTwainDirectOnTwain = Config.Get("executablePath", "");
                 szTwainDirectOnTwain = szTwainDirectOnTwain.Replace("TwainDirectScanner", "TwainDirectOnTwain");
@@ -2960,7 +2996,7 @@
             string szFunction = "DeviceScannerGetSession";

             // Protect our stuff...
-            lock (m_twainlocalsession)
+            lock (m_objectLock)
             {
                 //////////////////////////////////////////////////////////////////////
                 // This path is taken for getSession
@@ -3129,7 +3165,7 @@
             string szFunction = "DeviceScannerReadImageBlock";

             // Protect our stuff...
-            lock (m_twainlocalsession)
+            lock (m_objectLock)
             {
                 // State check...
                 switch (m_twainlocalsession.GetSessionState())
@@ -3224,7 +3260,7 @@
             string szFunction = "DeviceScannerReadImageBlockMetadata";

             // Protect our stuff...
-            lock (m_twainlocalsession)
+            lock (m_objectLock)
             {
                 // State check...
                 switch (m_twainlocalsession.GetSessionState())
@@ -3317,7 +3353,7 @@
             string szFunction = "DeviceScannerReleaseImageBlocks";

             // Protect our stuff...
-            lock (m_twainlocalsession)
+            lock (m_objectLock)
             {
                 // State check...
                 switch (m_twainlocalsession.GetSessionState())
@@ -3409,7 +3445,7 @@
             string szFunction = "DeviceScannerSendTask";

             // Protect our stuff...
-            lock (m_twainlocalsession)
+            lock (m_objectLock)
             {
                 // State check, we're allowing this to happen in more
                 // than just the ready state to support custom vendor
@@ -3531,7 +3567,7 @@
             string szFunction = "DeviceScannerStartCapturing";

             // Protect our stuff...
-            lock (m_twainlocalsession)
+            lock (m_objectLock)
             {
                 // State check...
                 if (m_twainlocalsession.GetSessionState() != SessionState.ready)
@@ -3621,7 +3657,7 @@
             string szFunction = "DeviceScannerStopCapturing";

             // Protect our stuff...
-            lock (m_twainlocalsession)
+            lock (m_objectLock)
             {
                 // State check...
                 switch (m_twainlocalsession.GetSessionState())
@@ -3843,9 +3879,19 @@
         #region Private Attributes...

         /// <summary>
-        /// All of the data we need to use TWAIN Local...
+        /// Use this with the /privet/info command...
+        /// </summary>
+        private TwainLocalSession m_twainlocalsessionInfo;
+
+        /// <summary>
+        /// All of the data we need for /privet/twaindirect/session...
         /// </summary>
         private TwainLocalSession m_twainlocalsession;
+
+        /// <summary>
+        /// Something we can lock...
+        /// </summary>
+        private object m_objectLock;

         /// <summary>
         /// Information about our device...


New clientlib ver

New clientlib ver

--- KalturaClient/Client.cs
+++ KalturaClient/Client.cs
@@ -36,7 +36,7 @@
 		public Client(Configuration config) : base(config)
 		{
 				ApiVersion = "16.10.0";
-				ClientTag = "dotnet:20-10-31";
+				ClientTag = "dotnet:20-11-01";
 		}

 		#region Properties


:memo: add xmldocs for Commandline

:memo: add xmldocs for Commandline

--- source/Utils/PeanutButter.Utils/Commandline.cs
+++ source/Utils/PeanutButter.Utils/Commandline.cs
@@ -17,7 +17,14 @@
 #endif
         class Commandline
     {
+        /// <summary>
+        /// The base command (program, batch file, etc) for this commandline
+        /// </summary>
         public string Command { get; }
+
+        /// <summary>
+        /// The arguments passed to this command
+        /// </summary>
         public string[] Args { get; }

         /// <summary>
@@ -72,20 +79,35 @@
             return str;
         }

-        public static Commandline Parse(string app)
+        /// <summary>
+        /// Parse a commandline into the command and args components
+        /// </summary>
+        /// <param name="commandline"></param>
+        /// <returns></returns>
+        public static Commandline Parse(string commandline)
         {
-            var parts = (app ?? "").SplitCommandline();
+            var parts = (commandline ?? "").SplitCommandline();
             return new Commandline(
                 parts[0],
                 parts.Skip(1).ToArray()
             );
         }

+        /// <summary>
+        /// Implicitly cast a Commandline instance to a string
+        /// </summary>
+        /// <param name="o"></param>
+        /// <returns></returns>
         public static implicit operator string(Commandline o)
         {
             return o.ToString();
         }

+        /// <summary>
+        /// Implicitly cast a commandline string to a Commandline instance
+        /// </summary>
+        /// <param name="s"></param>
+        /// <returns></returns>
         public static implicit operator Commandline(string s)
         {
             return Parse(s);


New clientlib ver

New clientlib ver

--- KalturaClient/Client.cs
+++ KalturaClient/Client.cs
@@ -36,7 +36,7 @@
 		public Client(Configuration config) : base(config)
 		{
 				ApiVersion = "16.5.0";
-				ClientTag = "dotnet:20-06-25";
+				ClientTag = "dotnet:20-06-26";
 		}

 		#region Properties


New clientlib ver

New clientlib ver

--- KalturaClient/Client.cs
+++ KalturaClient/Client.cs
@@ -36,7 +36,7 @@
 		public Client(Configuration config) : base(config)
 		{
 				ApiVersion = "16.11.0";
-				ClientTag = "dotnet:20-11-09";
+				ClientTag = "dotnet:20-11-10";
 		}

 		#region Properties


New clientlib ver

New clientlib ver

--- KalturaClient/Client.cs
+++ KalturaClient/Client.cs
@@ -36,7 +36,7 @@
 		public Client(Configuration config) : base(config)
 		{
 				ApiVersion = "17.12.0";
-				ClientTag = "dotnet:21-10-28";
+				ClientTag = "dotnet:21-10-29";
 		}

 		#region Properties


New clientlib ver

New clientlib ver

--- KalturaClient/Client.cs
+++ KalturaClient/Client.cs
@@ -36,7 +36,7 @@
 		public Client(Configuration config) : base(config)
 		{
 				ApiVersion = "3.3.0";
-				ClientTag = "dotnet:17-11-26";
+				ClientTag = "dotnet:17-11-27";
 		}

 		#region Properties


found a fix - use dbSet.Local instead of dbSet

--- ATPTennisStat/ATPTennisStat.Repositories/EfRepository.cs
+++ ATPTennisStat/ATPTennisStat.Repositories/EfRepository.cs
@@ -50,8 +50,16 @@
         {
             this.dbSet.Add(entity);

-            var a = this.context.Entry<TEntity>(entity);
-            var state = a.State;
+            var dbSetLocalToList = this.dbSet.Local.ToList();
+
+            var entry = this.context.Entry<TEntity>(entity);
+            var state = entry.State;
+            //state = System.Data.Entity.EntityState.Modified;
+
+            var dbSetToList = this.dbSet.AsEnumerable().ToList();
+            var dbSet = this.dbSet;
+
+
         }

         public void Remove(TEntity entity)


починил парсертест

починил парсертест

--- Lens.Test/ParserTest.cs
+++ Lens.Test/ParserTest.cs
@@ -835,7 +835,7 @@
 					Expression = new CastOperatorNode
 					{
 						Expression = new GetIdentifierNode("b"),
-						Type = "List<int>"
+						TypeSignature = "List<int>"
 					}
 				}
 			};


UWP fix

UWP fix

--- Assets/AzureServicesForUnity/Storage/StorageUtilities.cs
+++ Assets/AzureServicesForUnity/Storage/StorageUtilities.cs
@@ -5,6 +5,16 @@
 using System.Text;
 using UnityEngine;
 using UnityEngine.Networking;
+
+#if NETFX_CORE
+
+using Windows.Security.Cryptography.Core;
+
+using Windows.Security.Cryptography;
+
+using System.Runtime.InteropServices.WindowsRuntime;
+
+#endif

 namespace AzureServicesForUnity.Storage
 {
@@ -73,11 +83,19 @@

         private static string ComputeHmac256(byte[] key, string message)
         {
+#if NETFX_CORE
+
+			MacAlgorithmProvider provider = MacAlgorithmProvider.OpenAlgorithm(MacAlgorithmNames.HmacSha256);
+			CryptographicHash hash = provider.CreateHash(key.AsBuffer());
+			hash.Append(CryptographicBuffer.ConvertStringToBinary(message, BinaryStringEncoding.Utf8));
+			return CryptographicBuffer.EncodeToBase64String(hash.GetValueAndReset());
+#else
             using (HashAlgorithm hashAlgorithm = new HMACSHA256(key))
             {
                 byte[] messageBuffer = Encoding.UTF8.GetBytes(message);
                 return Convert.ToBase64String(hashAlgorithm.ComputeHash(messageBuffer));
             }
+#endif
         }

         private static string GetAuthorization(string accountName, string signature)


Guard against potential null ref

Guard against potential null ref

--- Assets/MRTK/Core/Utilities/Editor/XRSettingsUtilities.cs
+++ Assets/MRTK/Core/Utilities/Editor/XRSettingsUtilities.cs
@@ -202,9 +202,16 @@
             {
                 BuildTargetGroup currentBuildTarget = BuildPipeline.GetBuildTargetGroup(EditorUserBuildSettings.activeBuildTarget);
                 XRGeneralSettings settingsOfCurrentTarget = XRGeneralSettingsPerBuildTarget.XRGeneralSettingsForBuildTarget(currentBuildTarget);
+                if (settingsOfCurrentTarget != null && settingsOfCurrentTarget.AssignedSettings != null)
+                {
 #pragma warning disable CS0618 // Suppressing the warning to support xr management plugin 3.x and 4.x
-                return settingsOfCurrentTarget.AssignedSettings.loaders;
+                    return settingsOfCurrentTarget.AssignedSettings.loaders;
 #pragma warning restore CS0618
+                }
+                else
+                {
+                    return System.Array.Empty<XRLoader>();
+                }
             }
         }
 #endif // XR_MANAGEMENT_ENABLED


Improve ArrayPool performance(uses SpinLock)

--- Assets/Plugins/UniRx/Scripts/Async/Internal/ArrayPool.cs
+++ Assets/Plugins/UniRx/Scripts/Async/Internal/ArrayPool.cs
@@ -1,6 +1,7 @@
 #pragma warning disable CS1591 // Missing XML comment for publicly visible type or member

 using System;
+using System.Threading;

 namespace UniRx.Async.Internal
 {
@@ -16,14 +17,17 @@
         public static readonly ArrayPool<T> Shared = new ArrayPool<T>();

         readonly MinimumQueue<T[]>[] buckets;
+        readonly SpinLock[] locks;

         ArrayPool()
         {
             // see: GetQueueIndex
             buckets = new MinimumQueue<T[]>[18];
+            locks = new SpinLock[18];
             for (int i = 0; i < buckets.Length; i++)
             {
                 buckets[i] = new MinimumQueue<T[]>(4);
+                locks[i] = new SpinLock(false);
             }
         }

@@ -43,12 +47,19 @@
             if (index != -1)
             {
                 var q = buckets[index];
-                lock (q)
+                var lockTaken = false;
+                try
                 {
+                    locks[index].Enter(ref lockTaken);
+
                     if (q.Count != 0)
                     {
                         return q.Dequeue();
                     }
+                }
+                finally
+                {
+                    if (lockTaken) locks[index].Exit(false);
                 }
             }

@@ -71,14 +82,22 @@
                 }

                 var q = buckets[index];
-                lock (q)
+                var lockTaken = false;
+
+                try
                 {
+                    locks[index].Enter(ref lockTaken);
+
                     if (q.Count > DefaultMaxNumberOfArraysPerBucket)
                     {
                         return;
                     }

                     q.Enqueue(array);
+                }
+                finally
+                {
+                    if (lockTaken) locks[index].Exit(false);
                 }
             }
         }


fix leap/keyboard on custom gzme

fix leap/keyboard on custom gzme

--- Assets/scripts/controllers/menus/CustomMenuController.cs
+++ Assets/scripts/controllers/menus/CustomMenuController.cs
@@ -85,6 +85,14 @@
 			canvas.SetActive(true);
 			launchBrowser.Cancel = false;
 		}
+
+		//If leap is not connected
+		controllerLM = new Controller();
+		if(controllerLM != null && controllerLM.IsConnected){
+			LM = true;
+		} else {
+			LM = false;
+		}

 	}

@@ -131,6 +139,13 @@
 		if (monk) GameModel.Hero = new Monk();
 		if (wizard) GameModel.Hero = new Wizard();
 		GameModel.Hero.Name = userName;
+
+		//If leap is not connected
+		controllerLM = new Controller();
+
+		GameModel.PlayWithLeap = LM;
+		Debug.Log ("PLAYWITHLEAP : " + GameModel.PlayWithLeap);
+
 		Application.LoadLevel("GameScene");
 	}


Cleanup for SiteArmManager.cs

Cleanup for SiteArmManager.cs

--- AzureFunctions/Code/ArmManagerPartials/SiteArmManager.cs
+++ AzureFunctions/Code/ArmManagerPartials/SiteArmManager.cs
@@ -63,7 +63,7 @@
         {
             await _client.PostAsync(ArmUriTemplates.WebsitesRegister.Bind(resourceGroup), NullContent);

-            var siteName = $"Functions{Guid.NewGuid().ToString().Split('-').First()}";
+            var siteName = $"{Constants.FunctionsSitePrefix}{Guid.NewGuid().ToString().Split('-').First()}";
             var site = new Site(resourceGroup.SubscriptionId, resourceGroup.ResourceGroupName, siteName);
             var siteResponse = await _client.PutAsJsonAsync(ArmUriTemplates.Site.Bind(site), new { properties = new { serverFarmId = serverFarmId }, location = resourceGroup.Location });
             var armSite = await siteResponse.EnsureSuccessStatusCodeWithFullError();
@@ -151,11 +151,10 @@
             return site;
         }

-        public async Task<Site> UpdateConfig(this Site site, object config)
+        public async Task<Site> UpdateConfig(Site site, object config)
         {
             var response = await _client.PutAsJsonAsync(ArmUriTemplates.SiteConfig.Bind(site), config);
             await response.EnsureSuccessStatusCodeWithFullError();
-
             return site;
         }
     }


Deleting legacy DBriize database if present

--- BTCPayServer/HostedServices/DbMigrationsHostedService.cs
+++ BTCPayServer/HostedServices/DbMigrationsHostedService.cs
@@ -1,7 +1,9 @@
 using System;
 using System.Collections.Generic;
 using System.Globalization;
+using System.IO;
 using System.Threading.Tasks;
+using BTCPayServer.Configuration;
 using BTCPayServer.Data;
 using BTCPayServer.Services;
 using BTCPayServer.Services.Invoices;
@@ -16,12 +18,14 @@
         private readonly InvoiceRepository _invoiceRepository;
         private readonly SettingsRepository _settingsRepository;
         private readonly ApplicationDbContextFactory _dbContextFactory;
+        private readonly DataDirectories _datadirs;

-        public DbMigrationsHostedService(InvoiceRepository invoiceRepository, SettingsRepository settingsRepository, ApplicationDbContextFactory dbContextFactory)
+        public DbMigrationsHostedService(InvoiceRepository invoiceRepository, SettingsRepository settingsRepository, ApplicationDbContextFactory dbContextFactory, DataDirectories datadirs)
         {
             _invoiceRepository = invoiceRepository;
             _settingsRepository = settingsRepository;
             _dbContextFactory = dbContextFactory;
+            _datadirs = datadirs;
         }

@@ -43,6 +47,14 @@

         private async Task MigratedInvoiceTextSearchToDb(int startFromPage)
         {
+            // deleting legacy DBriize database if present
+            var dbpath = Path.Combine(_datadirs.DataDir, "InvoiceDB");
+            if (Directory.Exists(dbpath))
+            {
+                Directory.Delete(dbpath, true);
+            }
+
+            // migrate data to new table using invoices from database
             using var ctx = _dbContextFactory.CreateContext();

             var invoiceQuery = new InvoiceQuery { IncludeArchived = true };


Adjusted property be null

Adjusted property be null

--- BinanceExchange.API/Models/Request/CreateOrderRequest.cs
+++ BinanceExchange.API/Models/Request/CreateOrderRequest.cs
@@ -25,7 +25,7 @@

         [DataMember(Order = 4)]
         [JsonConverter(typeof(StringEnumConverter))]
-        public TimeInForce TimeInForce { get; set; }
+        public TimeInForce? TimeInForce { get; set; }

         [DataMember(Order = 5)]
         public decimal Quantity { get; set; }


Code cleanup

Code cleanup

--- CSharp.Readability/Connect/ReadabilityServiceProvider.cs
+++ CSharp.Readability/Connect/ReadabilityServiceProvider.cs
@@ -52,7 +52,7 @@
         /// <returns>A binding to the service provider's API.</returns>
 		public override IReadability GetApi(string accessToken, string secret)
         {
-			return new ReadabilityTemplate(ConsumerKey, this.ConsumerSecret, accessToken, secret);
+			return new ReadabilityTemplate(ConsumerKey, ConsumerSecret, accessToken, secret);
         }
     }
 }


price formating

price formating

--- CdesPrintingPricer/CdesPrintingPricer/MainWindow.xaml.cs
+++ CdesPrintingPricer/CdesPrintingPricer/MainWindow.xaml.cs
@@ -31,7 +31,7 @@

 // TO DO
 // Add Pdf Portfolio Support
-// Add Price Boxes
+// Add Total Cost Box
 // Add functionality to manually enter data, a calculator
 // Add functionality for multiple file selection, place in own container for auto population
 // Add functionality to populate individual containers for each file
@@ -308,7 +308,7 @@
         }

-        private void pageCost_Checked(object sender, RoutedEventArgs e)
+        public void pageCost_Checked(object sender, RoutedEventArgs e)
         {
             var pageBox = sender as CheckBox;
             var pageLayout = pageBox.Parent as FrameworkElement;
@@ -316,34 +316,34 @@
             string nameId;
             nameId = Regex.Match(name, @"\d+").Value;
             int i = Convert.ToInt32(nameId);
-            CalculateCost(nameId, i);
-        }
-
-
-        private void CalculateCost  (string nameId, int i)
-        {
-                TextBox pageCostBox = (TextBox)this.FindName(string.Format("pageCostBox_{0}", i + 1));
-                i--;
-                TextBox pageSizeBox = (TextBox)this.FindName(string.Format("pageSizeBox_{0}", i + 1));
-                {
-                    if (chooseBond.IsChecked == true)
-                    {
-                        double totalPageCost = costBond * (Convert.ToDouble(lengthToCharge) / 12);
-                        pageCostBox.Text = Convert.ToString(totalPageCost);
-                    }
-
-                    if (chooseMatte.IsChecked == true)
-                    {
-                        double totalPageCost = costMatte * (Convert.ToDouble(lengthToCharge) / 12);
-                        pageCostBox.Text = Convert.ToString(totalPageCost);
-                    }
-
-                    if (chooseSatin.IsChecked == true)
-                    {
-                        double totalPageCost = costSatin * (Convert.ToDouble(lengthToCharge) / 12);
-                        pageCostBox.Text = Convert.ToString(totalPageCost);
-                    }
-
+            CalculateCost(i);
+        }
+
+
+        private void CalculateCost(int i)
+        {
+            TextBox pageCostBox = (TextBox)this.FindName(string.Format("pageCostBox_{0}", i + 1));
+            i--;
+            TextBox pageSizeBox = (TextBox)this.FindName(string.Format("pageSizeBox_{0}", i + 1));
+            {
+                if (chooseBond.IsChecked == true)
+                {
+                    double totalPageCost = costBond * (Convert.ToDouble(lengthToCharge) / 12);
+                    pageCostBox.Text = "$ " + Convert.ToString(totalPageCost);
+                }
+
+                else if (chooseMatte.IsChecked == true)
+                {
+                    double totalPageCost = costMatte * (Convert.ToDouble(lengthToCharge) / 12);
+                    pageCostBox.Text = "$ " + Convert.ToString(totalPageCost);
+                }
+
+                else if (chooseSatin.IsChecked == true)
+                {
+                    double totalPageCost = costSatin * (Convert.ToDouble(lengthToCharge) / 12);
+                    pageCostBox.Text = "$ " + Convert.ToString(totalPageCost);
+                }
+
             }
         }

@@ -363,6 +363,7 @@
             TextBox pageCostBox = (TextBox)this.FindName(string.Format("pageCostBox_{0}", i + 1));
             i--;
             TextBox pageSizeBox = (TextBox)this.FindName(string.Format("pageSizeBox_{0}", i + 1));
+            i++;
             {
                 pageCostBox.Clear();
             }
@@ -375,31 +376,80 @@
                 i--;
                 TextBox pageSizeBox = (TextBox)this.FindName(string.Format("pageSizeBox_{0}", i + 1));
                 {
-                    pageCostBox.Text = "Worked";
+                    if (pageCostBox.Text != "")
+                    {
+                        if (chooseBond.IsChecked == true)
+                        {
+                            double totalPageCost = costBond * (Convert.ToDouble(lengthToCharge) / 12);
+                            pageCostBox.Text = "$ " + Convert.ToString(totalPageCost);
+                        }
+
+                        else if (chooseMatte.IsChecked == true)
+                        {
+                            double totalPageCost = costMatte * (Convert.ToDouble(lengthToCharge) / 12);
+                            pageCostBox.Text = "$ " + Convert.ToString(totalPageCost);
+                        }
+
+                        else if (chooseSatin.IsChecked == true)
+                        {
+                            double totalPageCost = costSatin * (Convert.ToDouble(lengthToCharge) / 12);
+                            pageCostBox.Text = "$ " + Convert.ToString(totalPageCost);
+                        }
+                    }
                 }
             }
         }

         private void chooseBond_Checked(object sender, RoutedEventArgs e)
         {
+            int i = 0;
             if (lengthToCharge != null)
             {
-            }
-
+                foreach (TextBox pageCostBox in stackCostLayout.Children)
+                {
+
+                    UpdateCost(i);
+                    i++;
+
+                }
+            }
+
+
+
         }

         private void chooseMatte_Checked(object sender, RoutedEventArgs e)
         {
             if (dlg.FileName != null)
             {
-            }
-
+                int i = 0;
+                if (lengthToCharge != null)
+                {
+                    foreach (TextBox pageCostBox in stackCostLayout.Children)
+                    {
+                        UpdateCost(i);
+                        i++;
+                    }
+                }
+            }
+
         }

         private void chooseSatin_Checked(object sender, RoutedEventArgs e)
         {
             if (dlg.FileName != null)
             {
+                int i = 0;
+                if (lengthToCharge != null)
+                {
+                    foreach (TextBox pageCostBox in stackCostLayout.Children)
+                    {
+
+                        UpdateCost(i);
+                        i++;
+
+                    }
+                }
             }
         }


fix the attribute name to expandJournal

fix the attribute name to expandJournal

--- ComputeClient/Compute.Contracts/Drs/ExpandJournalType.cs
+++ ComputeClient/Compute.Contracts/Drs/ExpandJournalType.cs
@@ -12,7 +12,7 @@
 	[System.Diagnostics.DebuggerStepThroughAttribute()]
 	[System.ComponentModel.DesignerCategoryAttribute("code")]
 	[System.Xml.Serialization.XmlTypeAttribute(Namespace = "urn:didata.com:api:cloud:types")]
-	[System.Xml.Serialization.XmlRootAttribute(Namespace = "urn:didata.com:api:cloud:types", IsNullable = true)]
+	[System.Xml.Serialization.XmlRootAttribute("expandJournal", Namespace = "urn:didata.com:api:cloud:types", IsNullable = true)]
 	public partial class ExpandJournalType
 	{
 		private int sizeGbField;


Restore Camera Monitoring toggleswitch

Restore Camera Monitoring toggleswitch

--- ConfigurationPage/PrinterSettings/PrinterSettingsView.cs
+++ ConfigurationPage/PrinterSettings/PrinterSettingsView.cs
@@ -197,6 +197,7 @@
 				CheckBox thisControl = sender as CheckBox;
 				PrinterSettings.Instance.set("PublishBedImage", thisControl.Checked ? "true" : "false");
 			};
+			publishImageSwitchContainer.AddChild(toggleSwitch);

 			publishImageSwitchContainer.SetBoundsToEncloseChildren();


game manager updated: new formation

game manager updated: new formation

--- Documents/Unity3D/Catcheep/Assets/Scripts/gameManager.cs
+++ Documents/Unity3D/Catcheep/Assets/Scripts/gameManager.cs
@@ -122,8 +122,9 @@
             {

                 if (taux < 2) taux += 0.065f;
-                int i = Random.Range(-5, 10);
-
+                int i = Random.Range(-5, 11);
+
+                i = 10;
                 switch (i)
                 {
                     case -5:
@@ -180,6 +181,10 @@
                         preMadeFormation(Random.Range(0,formationSheepys.Length));
                         //yield return new WaitForSeconds();
                         break;
+                    case 10:
+                        preMadeFormation(2);
+                        yield return new WaitForSeconds(1.5f);
+                        break;
                 }

             }


Bump version for last fix

Bump version for last fix


Culture based publishing

Culture based publishing

--- uSync8.ContentEdition/Serializers/ContentSerializer.cs
+++ uSync8.ContentEdition/Serializers/ContentSerializer.cs
@@ -41,7 +41,7 @@
             var node = InitializeNode(item, item.ContentType.Alias);

             var info = SerializeInfo(item);
-
+
             var properties = SerializeProperties(item);

             node.Add(info);
@@ -68,7 +68,7 @@
                 var template = fileService.GetTemplate(item.TemplateId.Value);
                 if (template != null)
                 {
-                    return new XElement("Template",
+                    return new XElement("Template",
                         new XAttribute("Key", template.Key),
                         template.Alias);
                 }
@@ -195,49 +195,51 @@

         protected virtual Attempt<string> DoSaveOrPublish(IContent item, XElement node)
         {
-            var info = node.Element("Info");
-
-            var trashed = info.Element("Trashed").ValueOrDefault(false);
-            if (trashed)
-            {
-                if (!item.Trashed)
-                {
-                    contentService.MoveToRecycleBin(item);
-                }
-                return Attempt.Succeed("Trashed");
-            }
-
-
-            if (item.Trashed)
-            {
-                // need to move it out of the trash.
-            }
-
-            var published = info.Element("Published")?.Attribute("Default").ValueOrDefault(false) ?? false;
-
-            if (published)
-            {
-                var publishResult = contentService.SaveAndPublish(item);
-                if (publishResult.Success)
-                    return Attempt.Succeed("Published");
-
-                return Attempt.Fail("Publish Failed " + publishResult.EventMessages);
-            }
-            else
-            {
-                var result = contentService.Save(item);
-                if (result.Success)
-                    return Attempt.Succeed("Saved");
-
-                return Attempt.Fail("Save Failed " + result.EventMessages);
-            }
-
-            // TODO: Culture based publishing
-
-        }
-
-
-
+
+            var publishedNode = node.Element("Info")?.Element("Published");
+            if (publishedNode != null)
+            {
+                if (publishedNode.HasElements)
+                {
+                    // culture based publishing.
+                    var publishedCultures = new List<string>();
+                    foreach (var culturePublish in publishedNode.Elements("Published"))
+                    {
+                        var culture = culturePublish.Attribute("Culture").ValueOrDefault(string.Empty);
+                        var status = culturePublish.ValueOrDefault(false);
+
+                        if (!string.IsNullOrWhiteSpace(culture) && status)
+                            publishedCultures.Add(culture);
+                    }
+
+                    if (publishedCultures.Count > 0)
+                    {
+                        contentService.SaveAndPublish(item, publishedCultures.ToArray());
+                        return Attempt.Succeed($"Published {publishedCultures.Count} Cultures");
+                    }
+                }
+                else
+                {
+                    // default publish the lot.
+                    if (publishedNode.Attribute("Default").ValueOrDefault(false))
+                    {
+                        var publishResult = contentService.SaveAndPublish(item);
+                        if (publishResult.Success)
+                            return Attempt.Succeed("Published");
+
+                        return Attempt.Fail("Publish Failed " + publishResult.EventMessages);
+                    }
+                }
+            }
+
+            // if we get here, save
+            var result = contentService.Save(item);
+            if (result.Success)
+                return Attempt.Succeed("Saved");
+
+            return Attempt.Fail("Save Failed " + result.EventMessages);
+        }
+
         #endregion

         protected override IContent CreateItem(string alias, ITreeEntity parent, string itemType)


Fix issue that was blocking multiple DataAnnotation rules from working when attached to a single property. bugid: 578

--- cslacs/Csla/Validation/CommonRules.cs
+++ cslacs/Csla/Validation/CommonRules.cs
@@ -1394,6 +1394,14 @@
       /// The attribute containing the rule implementation.
       /// </summary>
       public System.ComponentModel.DataAnnotations.ValidationAttribute Attribute { get; set; }
+
+      /// <summary>
+      /// Gets a string representation of the object.
+      /// </summary>
+      public override string ToString()
+      {
+        return string.Format("{0}?Attribute={1}", base.ToString(), Attribute.GetType().FullName);
+      }
     }

     /// <summary>


Check if field order has changed, if so update.

--- Core/OfficeDevPnP.Core/Framework/Provisioning/ObjectHandlers/ObjectContentType.cs
+++ Core/OfficeDevPnP.Core/Framework/Provisioning/ObjectHandlers/ObjectContentType.cs
@@ -130,6 +130,16 @@
                 existingContentType.Group = parser.ParseString(templateContentType.Group);
                 isDirty = true;
             }
+
+            // make sure fields are in the correct order
+            var existingFieldNames = existingContentType.FieldLinks.Select(fld => fld.Name).ToList();
+            var ctFieldNames = templateContentType.FieldRefs.Select(fld => parser.ParseString(fld.Name)).ToList();
+            if (!existingFieldNames.SequenceEqual(ctFieldNames))
+            {
+                existingContentType.FieldLinks.Reorder(templateContentType.FieldRefs.Select(fld => parser.ParseString(fld.Name)).ToArray());
+                isDirty = true;
+            }
+
             if (!isNoScriptSite)
             {
                 if (templateContentType.DisplayFormUrl != null && existingContentType.DisplayFormUrl != parser.ParseString(templateContentType.DisplayFormUrl))


Move EnsureProperties higher up as otherwise in can trigger executequery before the needed update statement. In this case this broke the fieldref ordering

--- Core/OfficeDevPnP.Core/Framework/Provisioning/ObjectHandlers/ObjectContentType.cs
+++ Core/OfficeDevPnP.Core/Framework/Provisioning/ObjectHandlers/ObjectContentType.cs
@@ -334,6 +334,7 @@
             var group = parser.ParseString(templateContentType.Group);

             var createdCT = web.CreateContentType(name, description, id, group);
+            createdCT.EnsureProperties(ct => ct.ReadOnly, ct => ct.Hidden, ct => ct.Sealed);

             List<FieldRef> fieldsRefsToProcess = new List<FieldRef>();
             foreach (FieldRef fr in templateContentType.FieldRefs)
@@ -384,8 +385,6 @@
             //will be added at the end. To fix this issue we ordering the fields once more.

             createdCT.FieldLinks.Reorder(templateContentType.FieldRefs.Select(fld => parser.ParseString(fld.Name)).ToArray());
-            createdCT.EnsureProperties(ct => ct.ReadOnly, ct => ct.Hidden, ct => ct.Sealed);
-
             if (createdCT.ReadOnly != templateContentType.ReadOnly)
             {
                 createdCT.ReadOnly = templateContentType.ReadOnly;


Small code optimization

Small code optimization

--- Core/OfficeDevPnP.Core/Framework/Provisioning/ObjectHandlers/ObjectContentType.cs
+++ Core/OfficeDevPnP.Core/Framework/Provisioning/ObjectHandlers/ObjectContentType.cs
@@ -333,15 +333,10 @@

             var createdCT = web.CreateContentType(name, description, id, group);

-            foreach (Field siteField in template.SiteFields)
-            {
-                siteField.SchemaXml = parser.ParseString(siteField.SchemaXml);
-            }
-
             List<FieldRef> fieldsRefsToProcess = new List<FieldRef>();
             foreach (FieldRef fr in templateContentType.FieldRefs)
             {
-                var templateField = template.SiteFields.FirstOrDefault(tf => (Guid)XElement.Parse(tf.SchemaXml).Attribute("ID") == fr.Id);
+                var templateField = template.SiteFields.FirstOrDefault(tf => tf.GetFieldId(parser) == fr.Id);
                 if (templateField == null || templateField.GetFieldProvisioningStep(parser) == _step)
                 {
                     fieldsRefsToProcess.Add(fr);
@@ -669,18 +664,18 @@
                         newCT.DocumentSetTemplate = new DocumentSetTemplate(
                             null, // TODO: WelcomePage not yet supported
                             (from allowedCT in documentSetTemplate.AllowedContentTypes.AsEnumerable()
-                             select allowedCT.StringValue).ToArray(),
+                             select allowedCT.StringValue).ToList(),
                             (from defaultDocument in documentSetTemplate.DefaultDocuments.AsEnumerable()
                              select new DefaultDocument
                              {
                                  ContentTypeId = defaultDocument.ContentTypeId.StringValue,
                                  Name = defaultDocument.Name,
                                  FileSourcePath = String.Empty, // TODO: How can we extract the proper file?!
-                             }).ToArray(),
+                             }).ToList(),
                             (from sharedField in documentSetTemplate.SharedFields.AsEnumerable()
-                             select sharedField.Id).ToArray(),
+                             select sharedField.Id).ToList(),
                             (from welcomePageField in documentSetTemplate.WelcomePageFields.AsEnumerable()
-                             select welcomePageField.Id).ToArray()
+                             select welcomePageField.Id).ToList()
                         );
                     }


fixed check for access modifier to return true if object does not care about visibility

--- Presentation.Web/Infrastructure/Authorization/OrganizationAuthorizationContext.cs
+++ Presentation.Web/Infrastructure/Authorization/OrganizationAuthorizationContext.cs
@@ -51,7 +51,7 @@
                 {
                     result = true;
                 }
-                else if (IsUserInMunicipality() && HasAssignedPublicAccess(entity))
+                else if (IsUserInMunicipality() && EntityIsNotRestrictedToLocalAccess(entity))
                 {
                     result = true;
                 }
@@ -126,9 +126,9 @@
             return entity is User;
         }

-        private static bool HasAssignedPublicAccess(IEntity entity)
+        private static bool EntityIsNotRestrictedToLocalAccess(IEntity entity)
         {
-            return (entity as IHasAccessModifier)?.AccessModifier == AccessModifier.Public;
+            return (entity as IHasAccessModifier)?.AccessModifier != AccessModifier.Local;
         }

         private bool IsUserInMunicipality()


Fixed Bug with frames per minute and frames per hour being changed to frames per second if they don't fit exactly within 1 day

--- Source/Applications/openHistorian/openHistorian/wwwroot/ExportDataHandler.ashx.cs
+++ Source/Applications/openHistorian/openHistorian/wwwroot/ExportDataHandler.ashx.cs
@@ -127,7 +127,7 @@

         private async Task CopyModelAsCsvToStreamAsync(SecurityPrincipal securityPrincipal, NameValueCollection requestParameters, Stream responseStream, CancellationToken cancellationToken)
         {
-            const int DefaultFrameRate = 30;
+            const double DefaultFrameRate = 30;

             string dateTimeFormat = Program.Host.Model.Global.DateTimeFormat;

@@ -199,9 +199,9 @@
                 headers = GetHeaders(dataContext, pointIDs.Select(id => (int)id));
             }

-            int frameRate;
-
-            if (!int.TryParse(frameRateParam, out frameRate))
+            double frameRate;
+
+            if (!double.TryParse(frameRateParam, out frameRate))
                 frameRate = DefaultFrameRate;

             bool alignTimestamps = alignTimestampsParam?.ParseBoolean() ?? true;
@@ -241,8 +241,19 @@
                         for (int i = 0; i < values.Length; i++)
                             values[i] = float.NaN;

-                        Ticks[] subseconds = Ticks.SubsecondDistribution(frameRate);
-                        ulong interval = (ulong)(subseconds.Length > 1 ? subseconds[1].Value : Ticks.PerSecond);
+                        ulong interval;
+
+                        if (Math.Abs(frameRate % 1) <= (Double.Epsilon * 100))
+                        {
+                            Ticks[] subseconds = Ticks.SubsecondDistribution((int)frameRate);
+
+                            interval = (ulong)(subseconds.Length > 1 ? subseconds[1].Value : Ticks.PerSecond);
+                        }
+                        else
+                        {
+                            interval = (ulong)(Math.Floor(1.0d / frameRate) * Ticks.PerSecond);
+                        }
+

                         ulong lastTimestamp = 0;

@@ -276,7 +287,7 @@
                             while (stream.Read(historianKey, historianValue) && !cancellationToken.IsCancellationRequested)
                             {
                                 if (alignTimestamps)
-                                    timestamp = (ulong)Ticks.RoundToSubsecondDistribution((long)historianKey.Timestamp, frameRate).Value;
+                                    timestamp = (ulong)Ticks.RoundToSecondDistribution((long)historianKey.Timestamp, frameRate, startTime.Ticks).Value;
                                 else
                                     timestamp = historianKey.Timestamp;

@@ -299,7 +310,7 @@

                                             for (ulong i = 1; i < difference / interval; i++)
                                             {
-                                                interpolated = (ulong)Ticks.RoundToSubsecondDistribution((long)(interpolated + interval), frameRate).Value;
+                                                interpolated = (ulong)Ticks.RoundToSecondDistribution((long)(interpolated + interval), frameRate, startTime.Ticks).Value;
                                                 readBuffer.Append($"{Environment.NewLine}{new DateTime((long)interpolated, DateTimeKind.Utc).ToString(dateTimeFormat)},");
                                                 bufferValues();
                                             }


Updated buttons on select group devices page to read "export/import" instead of "save/load" to better serve context.

--- Source/Applications/openHistorian/openHistorian/wwwroot/SelectGroupDevices.cshtml
+++ Source/Applications/openHistorian/openHistorian/wwwroot/SelectGroupDevices.cshtml
@@ -607,7 +607,7 @@

                     Selected Devices

-                    <button type="button" class="btn btn-sm" onclick="showSaveSelectionsFileNameDialog()" id="showSaveSelectionsFileNameDialog" data-bind="enable: selectedDevices().length > 0">Save</button>
+                    <button type="button" class="btn btn-sm" onclick="showSaveSelectionsFileNameDialog()" id="showSaveSelectionsFileNameDialog" data-bind="enable: selectedDevices().length > 0">Export</button>

                         <form class="form-inline" role="form">

@@ -622,7 +622,7 @@
                         </form>

-                    <button type="button" class="btn btn-sm" onclick="showLoadSelectionsFileNameDialog()">Load</button>
+                    <button type="button" class="btn btn-sm" onclick="showLoadSelectionsFileNameDialog()">Import</button>
                     <input id="loadSelectionsFileName" type="file" accept="text/json" style="position: fixed; top: -100em" onchange="loadSelectionsFile(event)">
                     <button type="button" class="btn btn-sm pull-right" data-bind="click: clearSelectedDevices.bind($data)">Clear All</button>


[Toolkit.Game] Refactor code in GameWindowPhoneBackgroundXaml for WP8

--- Source/Toolkit/SharpDX.Toolkit.Game/WindowsPhone/GameWindowPhoneBackgroundXaml.cs
+++ Source/Toolkit/SharpDX.Toolkit.Game/WindowsPhone/GameWindowPhoneBackgroundXaml.cs
@@ -1,4 +1,4 @@
-// Copyright (c) 2010-2013 SharpDX - Alexandre Mutel
+// Copyright (c) 2010-2012 SharpDX - Alexandre Mutel
 //
 // Permission is hereby granted, free of charge, to any person obtaining a copy
 // of this software and associated documentation files (the "Software"), to deal
@@ -17,6 +17,7 @@
 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 // THE SOFTWARE.
+
 #if WP8

 using System;
@@ -24,44 +25,69 @@
 using System.Runtime.InteropServices;
 using System.Windows;
 using System.Windows.Controls;
+
 using SharpDX.Direct3D11;
 using SharpDX.Toolkit.Graphics;

 namespace SharpDX.Toolkit
 {
-    internal class GameWindowPhoneBackgroundXaml : GameWindow, IDrawingSurfaceBackgroundContentProviderNative,
-                                                          IInspectable, ICustomQueryInterface
+    internal class GameWindowPhoneBackgroundXaml : GameWindow,
+                                                   IDrawingSurfaceBackgroundContentProviderNative,
+                                                   IInspectable,
+                                                   ICustomQueryInterface
     {
+        #region Fields
+
+        private readonly RenderTargetLocal[] renderTargets = new RenderTargetLocal[3];
+
+        private readonly IntPtr thisComObjectPtr;
+
         private RenderTarget2D backBuffer;
+
+        private Device currentDevice;
+
+        private DeviceContext currentDeviceContext;
+
+        private RenderTargetView currentRenderTargetView;
+
+        private Exception drawException;
+
+        private DrawingSurfaceBackgroundGrid drawingSurfaceBackgroundGrid;
+
         private GraphicsDevice graphicsDevice;
-        private Device currentDevice;
-        private DeviceContext currentDeviceContext;
-        private RenderTargetView currentRenderTargetView;
+
+        private IGraphicsDeviceManager graphicsDeviceManager;
+
+        private RenderTargetGraphicsPresenter graphicsPresenter;
+
+        private DrawingSurfaceRuntimeHost host;

         private bool isInitialized;

-        private IGraphicsDeviceManager graphicsDeviceManager;
-        private readonly IntPtr thisComObjectPtr;
-
-        private DrawingSurfaceBackgroundGrid drawingSurfaceBackgroundGrid;
-        private DrawingSurfaceRuntimeHost host;
+        private int nextRenderTarget;
+
+        #endregion
+
+        #region Constructors and Destructors

         internal GameWindowPhoneBackgroundXaml()
         {
             thisComObjectPtr = CppObjectShadow.ToIntPtr<IDrawingSurfaceBackgroundContentProviderNative>(this);
         }

-        public override object NativeWindow
-        {
-            get { return drawingSurfaceBackgroundGrid; }
-        }
-
-        public override bool IsMouseVisible { get; set; }
+        #endregion
+
+        #region Public Properties

         public override bool AllowUserResizing
         {
-            get { return false; }
-            set { }
+            get
+            {
+                return false;
+            }
+            set
+            {
+            }
         }

         public override DrawingRectangle ClientBounds
@@ -78,12 +104,28 @@

         public override DisplayOrientation CurrentOrientation
         {
-            get { return DisplayOrientation.Default; }
+            get
+            {
+                return DisplayOrientation.Default;
+            }
         }

         public override bool IsMinimized
         {
-            get { return false; }
+            get
+            {
+                return false;
+            }
+        }
+
+        public override bool IsMouseVisible { get; set; }
+
+        public override object NativeWindow
+        {
+            get
+            {
+                return drawingSurfaceBackgroundGrid;
+            }
         }

         /// <summary>
@@ -94,22 +136,42 @@
         /// </value>
         public override bool Visible
         {
-            get { return true; }
-            set { }
-        }
-
-        #region Implementation of ICallbackable
+            get
+            {
+                return true;
+            }
+            set
+            {
+            }
+        }
+
+        #endregion
+
+        #region Explicit Interface Properties

         IDisposable ICallbackable.Shadow { get; set; }

         #endregion

-        #region Implementation of IDrawingSurfaceBackgroundContentProviderNative
-
-        private readonly RenderTargetLocal[] renderTargets = new RenderTargetLocal[3];
-        private Exception drawException;
-        private RenderTargetGraphicsPresenter graphicsPresenter;
-        private int nextRenderTarget;
+        #region Public Methods and Operators
+
+        public override void BeginScreenDeviceChange(bool willBeFullScreen)
+        {
+        }
+
+        public override void EndScreenDeviceChange(int clientWidth, int clientHeight)
+        {
+        }
+
+        #endregion
+
+        #region Explicit Interface Methods
+
+        CustomQueryInterfaceResult ICustomQueryInterface.GetInterface(ref Guid iid, out IntPtr ppv)
+        {
+            ppv = thisComObjectPtr;
+            return CustomQueryInterfaceResult.Handled;
+        }

         void IDrawingSurfaceBackgroundContentProviderNative.Connect(DrawingSurfaceRuntimeHost host, Device device)
         {
@@ -121,48 +183,17 @@
             // Don't perform any dispose here, as It seems that we are unable to get back to the application after (program access violation)
         }

-        private void DisposeAll()
-        {
-            // Dispose the graphics device
-            Utilities.Dispose(ref graphicsDevice);
-
-            for (int i = 0; i < renderTargets.Length; i++)
-            {
-                renderTargets[i].Dispose();
-            }
-            Utilities.Dispose(ref backBuffer);
-        }
-
-        void IDrawingSurfaceBackgroundContentProviderNative.PrepareResources(DateTime presentTargetTime,
-                                                                             ref DrawingSizeF desiredRenderTargetSize)
-        {
-        }
-
-        internal GraphicsDevice EnsureDevice()
-        {
-            if (graphicsDevice == null)
-            {
-                graphicsDevice = GraphicsDevice.New(currentDevice);
-
-                renderTargets[0].NativePointer = currentRenderTargetView.NativePointer;
-                renderTargets[0].RenderTarget = RenderTarget2D.New(graphicsDevice, currentRenderTargetView, true);
-                backBuffer = renderTargets[0].RenderTarget;
-                nextRenderTarget = (nextRenderTarget + 1) % renderTargets.Length;
-
-                graphicsPresenter = new RenderTargetGraphicsPresenter(graphicsDevice, backBuffer);
-                graphicsDevice.Presenter = graphicsPresenter;
-            }
-
-            return graphicsDevice;
-        }
-
-        void IDrawingSurfaceBackgroundContentProviderNative.Draw(Device device, DeviceContext context,
-                                                                 RenderTargetView renderTargetView)
+        void IDrawingSurfaceBackgroundContentProviderNative.Draw(
+            Device device,
+            DeviceContext context,
+            RenderTargetView renderTargetView)
         {
             try
             {
                 if (!Exiting)
                 {
+                    // Sets the current RenderTargetView
+                    currentRenderTargetView = renderTargetView;

                     // Create the GraphicsDevice here
                     if (!ComObject.EqualsComObject(device, currentDevice) ||
@@ -170,12 +201,13 @@
                     {
                         currentDevice = device;
                         currentDeviceContext = context;
-                        currentRenderTargetView = renderTargetView;
-
+
+                        // Dispose all previously allocated device/backbuffers
                         DisposeAll();

                         if (!isInitialized)
                         {
+                            // The InitCallback will call us back on EnsureDevice method
                             InitCallback();
                             isInitialized = true;
                         }
@@ -189,37 +221,9 @@
                         }
                     }

-                    // Find any previous render target that was already alocated.
-                    bool foundRenderTarget = false;
-                    foreach (RenderTargetLocal renderTargetLocal in renderTargets)
-                    {
-                        if (renderTargetLocal.NativePointer == renderTargetView.NativePointer)
-                        {
-                            backBuffer = renderTargetLocal.RenderTarget;
-                            graphicsPresenter.SetBackBuffer(backBuffer);
-                            foundRenderTarget = true;
-                            break;
-                        }
-                    }
-
-                    if (!foundRenderTarget)
-                    {
-                        // Dispose any previous render target.
-                        renderTargets[nextRenderTarget].Dispose();
-
-                        // Creates the new backBuffer and associated it to the GraphicsPresenter
-                        backBuffer = RenderTarget2D.New(graphicsDevice, renderTargetView, true);
-
-                        renderTargets[nextRenderTarget].NativePointer = renderTargetView.NativePointer;
-                        renderTargets[nextRenderTarget].RenderTarget = backBuffer;
-                        nextRenderTarget = (nextRenderTarget + 1)%renderTargets.Length;
-
-                        graphicsPresenter.SetBackBuffer(backBuffer);
-                    }
-
-                    // TODO: Check that new device/devicecontext/renderTargetView are the same
-                    // else we need to handle DeviceReset/Remove...etc.
-
+                    EnsurePresenter(false);
+
+                    // Call the main Game.Run loop
                     RunCallback();

                     // Aks the host for additional frame
@@ -235,47 +239,87 @@
             }
         }

-        private struct RenderTargetLocal
-        {
-            public IntPtr NativePointer;
-            public RenderTarget2D RenderTarget;
-
-            public void Dispose()
-            {
-                Utilities.Dispose(ref RenderTarget);
-                NativePointer = IntPtr.Zero;
-            }
-        }
-
-        #endregion
-
-        #region Implementation of ICustomQueryInterface
-
-        CustomQueryInterfaceResult ICustomQueryInterface.GetInterface(ref Guid iid, out IntPtr ppv)
-        {
-            ppv = thisComObjectPtr;
-            return CustomQueryInterfaceResult.Handled;
-        }
-
-        #endregion
-
-        public override void BeginScreenDeviceChange(bool willBeFullScreen)
-        {
-        }
-
-        public override void EndScreenDeviceChange(int clientWidth, int clientHeight)
-        {
-        }
+        private int frameCount = 0;
+
+        void IDrawingSurfaceBackgroundContentProviderNative.PrepareResources(
+            DateTime presentTargetTime,
+            ref DrawingSizeF desiredRenderTargetSize)
+        {
+        }
+
+        #endregion
+
+        #region Methods

         internal override bool CanHandle(GameContext gameContext)
         {
             return gameContext.ContextType == GameContextType.WindowsPhoneBackgroundXaml;
         }

+        /// <summary>
+        /// Creates a <see cref="GraphicsDevice"/> if not already created based from latest internal device.
+        /// </summary>
+        /// <returns>a instance of GraphicsDevice.</returns>
+        internal GraphicsDevice EnsureDevice()
+        {
+            if (graphicsDevice == null)
+            {
+                // Creates a GraphicsDevice from the current GraphicsDevice
+                graphicsDevice = GraphicsDevice.New(currentDevice);
+
+                // Reset the presenter
+                EnsurePresenter(true);
+            }
+
+            return graphicsDevice;
+        }
+
+        /// <summary>
+        /// Creates a <see cref="RenderTargetGraphicsPresenter" /> if not already created based from latest internal device.
+        /// </summary>
+        /// <param name="resetPresenter">if set to <c>true</c> [reset presenter].</param>
+        internal void EnsurePresenter(bool resetPresenter)
+        {
+            // Find any previous render target that was already alocated.
+            if (!resetPresenter)
+            {
+                foreach (RenderTargetLocal renderTargetLocal in renderTargets)
+                {
+                    if (renderTargetLocal.NativePointer == currentRenderTargetView.NativePointer)
+                    {
+                        backBuffer = renderTargetLocal.RenderTarget;
+                        graphicsPresenter.SetBackBuffer(backBuffer);
+                        return;
+                    }
+                }
+            }
+
+            // Creates the backbuffer
+            backBuffer = RenderTarget2D.New(graphicsDevice, currentRenderTargetView, true);
+
+            // Dispose any previous render target.
+            renderTargets[nextRenderTarget].Dispose();
+            renderTargets[nextRenderTarget].NativePointer = currentRenderTargetView.NativePointer;
+            renderTargets[nextRenderTarget].RenderTarget = backBuffer;
+            nextRenderTarget = (nextRenderTarget + 1) % renderTargets.Length;
+
+            if (resetPresenter)
+            {
+                graphicsPresenter = new RenderTargetGraphicsPresenter(graphicsDevice, backBuffer);
+                graphicsDevice.Presenter = graphicsPresenter;
+            }
+
+            graphicsPresenter.SetBackBuffer(backBuffer);
+        }
+
         internal override void Initialize(GameContext gameContext)
         {
-            drawingSurfaceBackgroundGrid = (DrawingSurfaceBackgroundGrid) gameContext.Control;
+            drawingSurfaceBackgroundGrid = (DrawingSurfaceBackgroundGrid)gameContext.Control;
             graphicsDeviceManager = (IGraphicsDeviceManager)Services.GetService(typeof(IGraphicsDeviceManager));
+        }
+
+        internal override void Resize(int width, int height)
+        {
         }

         internal override void Run()
@@ -286,23 +330,37 @@
             drawingSurfaceBackgroundGrid.Unloaded += drawingSurfaceBackgroundGrid_Unloaded;
         }

-        internal override void Resize(int width, int height)
-        {
-        }
-
         protected internal override void SetSupportedOrientations(DisplayOrientation orientations)
         {
         }

+        protected override void Dispose(bool disposeManagedResources)
+        {
+            drawingSurfaceBackgroundGrid.SetBackgroundContentProvider(null);
+
+            base.Dispose(disposeManagedResources);
+        }
+
         protected override void SetTitle(string title)
         {
         }

-        protected override void Dispose(bool disposeManagedResources)
-        {
-            drawingSurfaceBackgroundGrid.SetBackgroundContentProvider(null);
-
-            base.Dispose(disposeManagedResources);
+        private void DisposeAll()
+        {
+            // Dispose the graphics device
+            Utilities.Dispose(ref graphicsDevice);
+
+            // Dispose all allocated render targets
+            for (int i = 0; i < renderTargets.Length; i++)
+            {
+                renderTargets[i].Dispose();
+            }
+
+            // Dispose the backbuffer
+            Utilities.Dispose(ref backBuffer);
+
+            // Clears the presenter
+            graphicsPresenter = null;
         }

         private void DrawingSurfaceBackgroundGridOnLoaded(object sender, RoutedEventArgs routedEventArgs)
@@ -318,6 +376,29 @@
             // Set the background to run this instance
             drawingSurfaceBackgroundGrid.SetBackgroundContentProvider(null);
         }
+
+        #endregion
+
+        private struct RenderTargetLocal
+        {
+            #region Fields
+
+            public IntPtr NativePointer;
+
+            public RenderTarget2D RenderTarget;
+
+            #endregion
+
+            #region Public Methods and Operators
+
+            public void Dispose()
+            {
+                Utilities.Dispose(ref RenderTarget);
+                NativePointer = IntPtr.Zero;
+            }
+
+            #endregion
+        }
     }
 }


Replace all inner paragraph blocks with newline, but not the last one!

--- WinMasto/Tools/Extensions/InteractiveText.cs
+++ WinMasto/Tools/Extensions/InteractiveText.cs
@@ -14,8 +14,18 @@
 {
     public static class HtmlRemoval
     {
-        public static string StripTagsCharArray(string source)
+        public static string StripTagsCharArray(string test)
         {
+            // Replace all inner paragraph blocks with newline.
+            string source;
+            try
+            {
+                source = new StringBuilder(test).Replace("
", "\r\n\r\n", 0, test.LastIndexOf("
")).ToString();
+            }
+            catch (Exception)
+            {
+                source = test;
+            }
             char[] array = new char[source.Length];
             int arrayIndex = 0;
             bool inside = false;


Update source template

Update source template

--- visual-studio-csharp/VainZero.Procon.CSharp/Program.cs
+++ visual-studio-csharp/VainZero.Procon.CSharp/Program.cs
@@ -89,32 +89,34 @@

         while (true)
         {
-            var c = reader.Read();
-
-            if (c == '\r')
+            var r = reader.Read();
+
+            if (r == '\r')
             {
                 if (reader.Peek() == '\n') reader.Read();
                 break;
             }
-            else if (c == -1 || c == ' ' || c == '\n')
+            else if (r == -1 || r == ' ' || r == '\n')
             {
                 break;
             }
             else
             {
+                var c = (char)r;
+
                 switch (count)
                 {
                     case 0:
-                        firstChar = (char)c;
+                        firstChar = c;
                         count = 1;
                         break;
                     case 1:
                         sb = new StringBuilder();
-                        sb.Append(firstChar).Append((char)c);
+                        sb.Append(firstChar).Append(c);
                         count = 2;
                         break;
                     default:
-                        sb.Append((char)c);
+                        sb.Append(c);
                         break;
                 }
             }
@@ -182,7 +184,7 @@
     /// <summary>
     /// Reads next line and splits it by spaces.
     /// </summary>
-    public IEnumerable<X> Words<X>(Func<string, X> func)
+    public X[] Words<X>(Func<string, X> func)
     {
         return reader.ReadLine().Split(' ').Select(func).ToArray();
     }


* Implemented CanBecomeKey in WPF WindowFrameBackend * Ignore -1 width or height on WPF WindowFrameBackend SetSize method

--- Xwt.WPF/Xwt.WPFBackend/WindowFrameBackend.cs
+++ Xwt.WPF/Xwt.WPFBackend/WindowFrameBackend.cs
@@ -160,8 +160,10 @@
 		{
 			get { return window.Visibility == Visibility.Visible; }
 			set {
-				if (value)
+				if (value) {
+					window.ShowActivated = ((Window)Frontend).CanBecomeKey;
 					window.Show ();
+				}
 				else
 					window.Hide ();
 			}
@@ -208,8 +210,12 @@
 		public void SetSize (double width, double height)
 		{
 			var r = Bounds;
-			r.Width = width;
-			r.Height = height;
+			if (width > -1) {
+				r.Width = width;
+			}
+			if (height > -1) {
+				r.Height = height;
+			}
 			Bounds = r;
 		}


Added comment, made third argument optional

--- src/AngleSharp/Parser/Html/Tokens/HtmlToken.cs
+++ src/AngleSharp/Parser/Html/Tokens/HtmlToken.cs
@@ -19,12 +19,13 @@

         #region ctor

-        public HtmlToken(HtmlTokenType type, TextPosition position)
-            : this(type, position, null)
-        {
-        }
-
-        public HtmlToken(HtmlTokenType type, TextPosition position, String name)
+        /// <summary>
+        /// Creates a new HTML token.
+        /// </summary>
+        /// <param name="type">The exact type of the token.</param>
+        /// <param name="position">The token's text position.</param>
+        /// <param name="name">The optional name of the token, if any.</param>
+        public HtmlToken(HtmlTokenType type, TextPosition position, String name = null)
         {
             _type = type;
             _position = position;


Parallelized Pixmap.SetPixelDataArgb for a cheap 10% performance improvement.

--- Duality/Resources/Pixmap.cs
+++ Duality/Resources/Pixmap.cs
@@ -5,7 +5,7 @@
 using System.Drawing.Imaging;
 using System.IO;
 using System.Reflection;
-
+using System.Threading.Tasks;
 using Duality.ColorFormat;
 using Duality.EditorHints;
 using Duality.Serialization;
@@ -392,8 +392,10 @@
 				if (this.data == null || this.data.Length != this.width * this.height)
 					this.data = new ColorRgba[this.width * this.height];

-				for (int i = 0; i < this.data.Length; i++)
-					this.data[i].SetIntArgb(pixelData[i]);
+				unchecked
+				{
+					Parallel.For(0, this.data.Length, i => this.data[i].SetIntArgb(pixelData[i]));
+				}
 			}

 			/// <summary>


Audio system fix.Update editor layer.

Audio system fix.Update editor layer.

--- Engine/Audio/AudioSystem.cs
+++ Engine/Audio/AudioSystem.cs
@@ -30,6 +30,13 @@
     public bool ambienceActive = false;

     public int soundIncrement = 0;
+
+	public string audioRootPath {
+		get {
+			return ContentsConfig.contentRootFolder + "/"
+				+ ContentsConfig.contentAppFolder + "/version/shared/audio/";
+		}
+	}

     public bool isAudiocurrentLoopPlaying {
         get {
@@ -128,18 +135,21 @@
     }

 	public void PlayEffect(Transform parentTransform, string name, bool loop, float volume) {
-		PlayFileFromResources(parentTransform, "Audio/" + name, loop, soundIncrement, volume);
+		PlayFileFromResources(parentTransform,
+			audioRootPath + name, loop, soundIncrement, volume);
 	}

 	public void PlayEffect(Transform parentTransform, string name, float volume) {
-		PlayFileFromResources(parentTransform, "Audio/" + name, false, soundIncrement, volume);
+		PlayFileFromResources(parentTransform,
+			audioRootPath + name, false, soundIncrement, volume);
 	}

     public void PlayEffect(string name, float volume) {

         // TODO, lookup filename from sound list...
         soundIncrement++;
-        PlayFileFromResources("Audio/" + name, false, soundIncrement, volume);
+        PlayFileFromResources(
+			audioRootPath + name, false, soundIncrement, volume);
     }

     public void PlayEffectIncrement(AudioClip clip, float volume, int increment) {
@@ -157,7 +167,7 @@
     }

     public void PlayEffectSingle() {
-        PlayFileFromResources("Audio/" + name, false);
+        PlayFileFromResources(audioRootPath + name, false);
     }

     public void PlayUIMainLoop(string name, float volume) {
@@ -184,8 +194,7 @@
     }

     public void PrepareIntroFileFromResources(string file, bool loop, double volume) { // file name without extension
-        if (file.IndexOf("Audio") == -1)
-            file = "Audio/" + file;
+        file = audioRootPath + file;
         currentIntroClip = LoadClipFromResources(file);
         GameObject goClip = GameObject.Find(file);
         if (goClip != null) {
@@ -225,8 +234,7 @@
     }

     public void PrepareGameLoopFileFromResources(string file, bool loop, double volume) { // file name without extension
-        if (file.IndexOf("Audio") == -1)
-            file = "Audio/" + file;
+        file = audioRootPath + file;
         currentGameLoopClip = LoadClipFromResources(file);
         GameObject goClip = GameObject.Find(file);
         if (goClip != null) {
@@ -245,8 +253,7 @@
     }

     public void PrepareLoopFileFromResources(string file, bool loop, float volume) { // file name without extension
-        if (file.IndexOf("Audio") == -1)
-            file = "Audio/" + file;
+        file = audioRootPath + file;
         currentLoopClip = LoadClipFromResources(file);
         GameObject goClip = GameObject.Find(file);
         if (goClip != null) {
@@ -266,8 +273,7 @@
     }

     public void PrepareGameLapLoopFileFromResources(int index, string file, bool loop, double volume) { // file name without extension
-        if (file.IndexOf("Audio") == -1)
-            file = "Audio/" + file;
+        file = audioRootPath  + file;
         currentGameClipLap[index] = LoadClipFromResources(file);
         GameObject goClip = GameObject.Find(file);
         if (goClip != null) {
@@ -482,7 +488,7 @@
     }

     public AudioClip LoadLoop(string name) {
-        AudioClip clip = LoadClipFromResources("Audio/" + name);
+        AudioClip clip = LoadClipFromResources(audioRootPath + name);
         return clip;
     }

@@ -501,8 +507,6 @@
     public IEnumerator StartAmbienceCoroutine() {

 		if(!ambienceActive) {
-
-			ambienceActive = true;

 	        if (currentGameLoop != null) {
 	            if (currentGameLoop.isPlaying) {
@@ -511,21 +515,23 @@
 	            }
 	        }

-	        if (currentIntro != null && ambienceActive) {
+	        if (currentIntro != null) {
 		        currentIntro.volume = (float)musicSoundVolume;
 		        currentIntro.Play();
-				if(currentIntro.clip != null) {
+				//if(currentIntro.clip != null) {
 	            	yield return new WaitForSeconds(currentIntro.clip.length - 1f);
-				}
+				//}
 	            currentIntro.gameObject.AudioTo(0f, 1f, 1f, 0f);
 			}
+
+			ambienceActive = true;

 	        if (currentLoop != null && ambienceActive) {

 	            currentLoop.volume = (float)musicSoundVolume;
 	            currentLoop.Play();
 	            currentLoop.gameObject.AudioTo((float)musicSoundVolume, 1f, 1f, 0f);
-	        }
+	        }
 		}
 		else {
 			yield break;


Whitespace and trigger a build

Whitespace and trigger a build

--- Facebook.Android/build.cake
+++ Facebook.Android/build.cake
@@ -20,12 +20,8 @@
 			SolutionPath = "./Xamarin.Facebook.sln",
 			BuildsOn = BuildPlatforms.Mac,
 			OutputFiles = new [] {
-				new OutputFileCopy {
-					FromFile = "./source/Xamarin.Facebook/bin/Release/Xamarin.Facebook.dll",
-				},
-				new OutputFileCopy {
-					FromFile = "./source/Xamarin.Facebook.AudienceNetwork/bin/Release/Xamarin.Facebook.AudienceNetwork.dll",
-				}
+				new OutputFileCopy { FromFile = "./source/Xamarin.Facebook/bin/Release/Xamarin.Facebook.dll" },
+				new OutputFileCopy { FromFile = "./source/Xamarin.Facebook.AudienceNetwork/bin/Release/Xamarin.Facebook.AudienceNetwork.dll" }
 			}
 		}
 	},
@@ -42,7 +38,7 @@
 	},

 	Components = new [] {
-		new Component { ManifestDirectory = "./component"},
+		new Component { ManifestDirectory = "./component" },
 	},
 };

@@ -50,16 +46,14 @@
 	.WithCriteria (!FileExists ("./externals/facebook.aar"))
 	.Does (() =>
 {
-	if (!DirectoryExists ("./externals/"))
-		CreateDirectory ("./externals");
+	EnsureDirectoryExists ("./externals/");

 	// Download the FB aar
 	DownloadFile (FB_URL, "./externals/facebook.aar");

 	// Download, and unzip the docs .jar
 	DownloadFile (FB_DOCS_URL, "./externals/facebook-docs.jar");
-	if (!DirectoryExists ("./externals/fb-docs"))
-		CreateDirectory ("./externals/fb-docs");
+	EnsureDirectoryExists ("./externals/fb-docs");
 	Unzip ("./externals/facebook-docs.jar", "./externals/fb-docs");

 	// Download the FB aar


fixed async retry delay on task

fixed async retry delay on task

--- FlubuCore/Tasks/TaskBase.cs
+++ FlubuCore/Tasks/TaskBase.cs
@@ -247,7 +247,7 @@
                 {
                     _retriedTimes++;
                     contextInternal.LogInfo($"Task failed. Retriying for {_retriedTimes} time(s). Number of all retries {NumberOfRetries}.");
-                    Thread.Sleep(RetryDelay);
+                    await Task.Delay(RetryDelay);
                     return await ExecuteAsync(context);
                 }

@@ -292,7 +292,7 @@

             foreach (var fromArgument in _fromArguments)
             {
-                if (!Context.ScriptArgs.ContainsKey(fromArgument.ArgKey))
+                if (! Context.ScriptArgs.ContainsKey(fromArgument.ArgKey))
                 {
                     fromArgument.TaskMethod.Compile().Invoke(this as TTask);
                     return;