diff options
Diffstat (limited to 'OpenSim/Framework')
-rw-r--r-- | OpenSim/Framework/Util.cs | 45 |
1 files changed, 29 insertions, 16 deletions
diff --git a/OpenSim/Framework/Util.cs b/OpenSim/Framework/Util.cs index 21cfc09..ed92b2d 100644 --- a/OpenSim/Framework/Util.cs +++ b/OpenSim/Framework/Util.cs | |||
@@ -58,10 +58,12 @@ namespace OpenSim.Framework | |||
58 | /// <remarks> | 58 | /// <remarks> |
59 | /// None is used to execute the method in the same thread that made the call. It should only be used by regression | 59 | /// None is used to execute the method in the same thread that made the call. It should only be used by regression |
60 | /// test code that relies on predictable event ordering. | 60 | /// test code that relies on predictable event ordering. |
61 | /// RegressionTest is used by regression tests. It fires the call synchronously and does not catch any exceptions. | ||
61 | /// </remarks> | 62 | /// </remarks> |
62 | public enum FireAndForgetMethod | 63 | public enum FireAndForgetMethod |
63 | { | 64 | { |
64 | None, | 65 | None, |
66 | RegressionTest, | ||
65 | UnsafeQueueUserWorkItem, | 67 | UnsafeQueueUserWorkItem, |
66 | QueueUserWorkItem, | 68 | QueueUserWorkItem, |
67 | BeginInvoke, | 69 | BeginInvoke, |
@@ -1544,27 +1546,38 @@ namespace OpenSim.Framework | |||
1544 | 1546 | ||
1545 | public static void FireAndForget(System.Threading.WaitCallback callback, object obj) | 1547 | public static void FireAndForget(System.Threading.WaitCallback callback, object obj) |
1546 | { | 1548 | { |
1547 | // When OpenSim interacts with a database or sends data over the wire, it must send this in en_US culture | 1549 | WaitCallback realCallback; |
1548 | // so that we don't encounter problems where, for instance, data is saved with a culture that uses commas | ||
1549 | // for decimals places but is read by a culture that treats commas as number seperators. | ||
1550 | WaitCallback realCallback = delegate(object o) | ||
1551 | { | ||
1552 | Culture.SetCurrentCulture(); | ||
1553 | 1550 | ||
1554 | try | 1551 | if (FireAndForgetMethod == FireAndForgetMethod.RegressionTest) |
1555 | { | 1552 | { |
1556 | callback(o); | 1553 | // If we're running regression tests, then we want any exceptions to rise up to the test code. |
1557 | } | 1554 | realCallback = o => { Culture.SetCurrentCulture(); callback(o); }; |
1558 | catch (Exception e) | 1555 | } |
1556 | else | ||
1557 | { | ||
1558 | // When OpenSim interacts with a database or sends data over the wire, it must send this in en_US culture | ||
1559 | // so that we don't encounter problems where, for instance, data is saved with a culture that uses commas | ||
1560 | // for decimals places but is read by a culture that treats commas as number seperators. | ||
1561 | realCallback = o => | ||
1559 | { | 1562 | { |
1560 | m_log.ErrorFormat( | 1563 | Culture.SetCurrentCulture(); |
1561 | "[UTIL]: Continuing after async_call_method thread terminated with exception {0}{1}", | 1564 | |
1562 | e.Message, e.StackTrace); | 1565 | try |
1563 | } | 1566 | { |
1564 | }; | 1567 | callback(o); |
1568 | } | ||
1569 | catch (Exception e) | ||
1570 | { | ||
1571 | m_log.ErrorFormat( | ||
1572 | "[UTIL]: Continuing after async_call_method thread terminated with exception {0}{1}", | ||
1573 | e.Message, e.StackTrace); | ||
1574 | } | ||
1575 | }; | ||
1576 | } | ||
1565 | 1577 | ||
1566 | switch (FireAndForgetMethod) | 1578 | switch (FireAndForgetMethod) |
1567 | { | 1579 | { |
1580 | case FireAndForgetMethod.RegressionTest: | ||
1568 | case FireAndForgetMethod.None: | 1581 | case FireAndForgetMethod.None: |
1569 | realCallback.Invoke(obj); | 1582 | realCallback.Invoke(obj); |
1570 | break; | 1583 | break; |