summaryrefslogtreecommitdiff
path: root/tests/src/baseservices/threading/mutex/openmutexcommon.cs
blob: fce7fc3044b13f81c54d55cd3499396db7d7bcd4 (plain)
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
// 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;

class Common
{
    public static string GenerateUnicodeString(int iNumChars)
    {
        Random rand = new Random();
        string semName = string.Empty;
        string semNameNum = string.Empty;
        for (int i = 0; i < iNumChars; i++)
        {
            char c = (char)rand.Next(Char.MinValue, Char.MaxValue);
            semNameNum += ((int)c).ToString() + ";";
            semName += (char)rand.Next(Char.MinValue, Char.MaxValue);
        }
        // write to output
        Console.WriteLine("Unicode string: " + semNameNum);
        return semName;
    }

    public static string GetUniqueName()
    {
        string sName = Guid.NewGuid().ToString();
        Console.WriteLine("Name created: " + sName);
        return sName;
    }
}