forked from nbauernfeind/deephaven-core
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUtility.cs
More file actions
47 lines (38 loc) · 921 Bytes
/
Utility.cs
File metadata and controls
47 lines (38 loc) · 921 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
using System.Diagnostics;
namespace Deephaven.ExcelAddIn.Util;
internal static class Utility {
public const string VersionString = "Version 0.8.0";
public static T Exchange<T>(ref T item, T newValue) {
var result = item;
item = newValue;
return result;
}
public static void RunInBackground(Action a) {
void Doit() {
try {
a();
} catch (Exception e) {
Debug.WriteLine($"Ignoring exception {e}");
}
}
new Thread(Doit) { IsBackground = true }.Start();
}
}
public class Unit {
public static readonly Unit Instance = new ();
private Unit() {
}
}
public class ValueHolder<T> where T : class {
private T? _value = null;
public T Value {
get {
if (_value == null) {
throw new Exception("Value is unset");
}
return _value;
}
set => _value = value;
}
}