summaryrefslogtreecommitdiff
path: root/tests/src/baseservices/threading/interlocked/exchange/exchanget.cs
diff options
context:
space:
mode:
Diffstat (limited to 'tests/src/baseservices/threading/interlocked/exchange/exchanget.cs')
-rw-r--r--tests/src/baseservices/threading/interlocked/exchange/exchanget.cs42
1 files changed, 42 insertions, 0 deletions
diff --git a/tests/src/baseservices/threading/interlocked/exchange/exchanget.cs b/tests/src/baseservices/threading/interlocked/exchange/exchanget.cs
new file mode 100644
index 0000000000..6e54966049
--- /dev/null
+++ b/tests/src/baseservices/threading/interlocked/exchange/exchanget.cs
@@ -0,0 +1,42 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System;
+using System.Threading;
+
+public class Test
+{
+
+ public static int Main()
+ {
+ Console.WriteLine("Start");
+ int retVal = 100;
+ string STORAGE = "OLD";
+ string NOW = "NOW";
+ string ret = "";
+
+ Console.WriteLine("ref loc: " + STORAGE);
+ Console.WriteLine("Return: " + ret);
+
+ Console.WriteLine("Echanging in:" + NOW);
+
+ string OLDSTORAGE = STORAGE;
+ ret = Interlocked.Exchange<string>(ref STORAGE,NOW);
+
+ Console.WriteLine("ref loc: " + STORAGE);
+ Console.WriteLine("Return: " + ret);
+
+ //if(ret == "" || STORAGE != NOW)
+ if(ret != OLDSTORAGE || STORAGE != NOW)
+ retVal = -1;
+
+ if (retVal == 100)
+ Console.WriteLine("Test passed");
+ else
+ Console.WriteLine("Test failed");
+
+ return retVal;
+
+ }
+}