You've already forked linux-packaging-mono
acceptance-tests
data
docs
eglib
external
ikvm-native
libgc
m4
man
mcs
build
class
Accessibility
Commons.Xml.Relaxng
Cscompmgd
CustomMarshalers
Facades
I18N
IBM.Data.DB2
ICSharpCode.SharpZipLib
Microsoft.Build
Microsoft.Build.Engine
Microsoft.Build.Framework
Microsoft.Build.Tasks
Microsoft.Build.Utilities
Microsoft.CSharp
Microsoft.VisualC
Microsoft.Web.Infrastructure
MicrosoftAjaxLibrary
Mono.C5
Mono.CSharp
Mono.Cairo
Mono.Cecil
Mono.Cecil.Mdb
Mono.CodeContracts
Mono.CompilerServices.SymbolWriter
Mono.Data.Sqlite
Mono.Data.Tds
Mono.Debugger.Soft
Mono.Dynamic.Interpreter
Mono.Http
Mono.Management
Mono.Messaging
Mono.Messaging.RabbitMQ
Mono.Options
Mono.Parallel
Mono.Posix
Mono.Security
Mono.Security.Providers.DotNet
Mono.Security.Providers.NewSystemSource
Mono.Security.Providers.NewTls
Mono.Security.Providers.OldTls
Mono.Security.Win32
Mono.Simd
Mono.Tasklets
Mono.WebBrowser
Mono.XBuild.Tasks
Novell.Directory.Ldap
PEAPI
RabbitMQ.Client
SMDiagnostics
System
System.ComponentModel.Composition.4.5
System.ComponentModel.DataAnnotations
System.Configuration
System.Configuration.Install
System.Core
System.Data
System.Data.DataSetExtensions
System.Data.Entity
System.Data.Linq
System.Data.OracleClient
System.Data.Services
System.Data.Services.Client
System.Design
System.DirectoryServices
System.DirectoryServices.Protocols
System.Drawing
System.Drawing.Design
System.Dynamic
System.EnterpriseServices
System.IO.Compression
System.IO.Compression.FileSystem
System.IdentityModel
System.IdentityModel.Selectors
System.Json
System.Json.Microsoft
System.Management
System.Messaging
System.Net
System.Net.Http
System.Net.Http.Formatting
System.Net.Http.WebRequest
System.Net.Http.WinHttpHandler
System.Numerics
System.Numerics.Vectors
System.Reactive.Core
System.Reactive.Debugger
System.Reactive.Experimental
System.Reactive.Interfaces
System.Reactive.Linq
System.Reactive.Observable.Aliases
System.Reactive.PlatformServices
System.Reactive.Providers
System.Reactive.Runtime.Remoting
System.Reactive.Windows.Forms
System.Reactive.Windows.Threading
System.Reflection.Context
System.Reflection.DispatchProxy
System.Runtime.Caching
System.Runtime.DurableInstancing
System.Runtime.InteropServices.RuntimeInformation
System.Runtime.Remoting
System.Runtime.Serialization
System.Runtime.Serialization.Formatters.Soap
System.Security
System.ServiceModel
System.ServiceModel.Activation
System.ServiceModel.Discovery
System.ServiceModel.Internals
System.ServiceModel.Routing
System.ServiceModel.Web
System.ServiceProcess
System.Threading.Tasks.Dataflow
System.Transactions
System.Web
System.Web.Abstractions
System.Web.ApplicationServices
System.Web.DynamicData
System.Web.Extensions
System.Web.Extensions.Design
System.Web.Http
System.Web.Http.SelfHost
System.Web.Http.WebHost
System.Web.Mvc3
System.Web.Razor
System.Web.Routing
System.Web.Services
System.Web.WebPages
System.Web.WebPages.Deployment
System.Web.WebPages.Razor
System.Windows
System.Windows.Forms
System.Windows.Forms.DataVisualization
System.XML
System.Xaml
System.Xml.Linq
System.Xml.Serialization
System.Xml.XPath.XmlDocument
SystemWebTestShim
WebMatrix.Data
WindowsBase
aot-compiler
corlib
Assembly
Documentation
Microsoft.Win32
Mono
Mono.Globalization.Unicode
Mono.Interop
Mono.Security
Mono.Security.Cryptography
Mono.Xml
ReferenceSources
System
System.Configuration.Assemblies
System.Deployment.Internal
System.Diagnostics
System.Diagnostics.SymbolStore
System.Diagnostics.Tracing
System.Globalization
System.IO
System.IO.IsolatedStorage
System.Reflection
System.Reflection.Emit
System.Reflection.Metadata
System.Resources
System.Runtime
System.Runtime.CompilerServices
System.Runtime.Hosting
System.Runtime.InteropServices
System.Runtime.InteropServices.WindowsRuntime
System.Runtime.Loader
System.Runtime.Remoting
System.Runtime.Remoting.Activation
System.Runtime.Remoting.Channels
System.Runtime.Remoting.Contexts
System.Runtime.Remoting.Lifetime
System.Runtime.Remoting.Messaging
System.Runtime.Remoting.Metadata
System.Runtime.Remoting.Metadata.W3cXsd2001
System.Runtime.Remoting.Proxies
System.Runtime.Remoting.Services
System.Runtime.Versioning
System.Security
System.Security.AccessControl
System.Security.Cryptography
System.Security.Cryptography.X509Certificates
System.Security.Permissions
System.Security.Policy
System.Security.Principal
System.Text
System.Threading
System.Threading.Tasks
Test
Microsoft.Win32
Mono
System
System.Collections
System.Collections.Concurrent
System.Collections.Generic
System.Collections.ObjectModel
System.Diagnostics
System.Diagnostics.Contracts
System.Globalization
System.IO
System.IO.IsolatedStorage
System.Reflection
System.Reflection.Emit
System.Resources
System.Runtime.CompilerServices
System.Runtime.ExceptionServices
System.Runtime.InteropServices
System.Runtime.Remoting
System.Runtime.Remoting.Channels
System.Runtime.Remoting.Contexts
System.Runtime.Remoting.Messaging
System.Runtime.Remoting.Metadata.W3cXsd2001
System.Runtime.Serialization
System.Runtime.Serialization.Formatters.Binary
System.Runtime.Versioning
System.Security
System.Security.AccessControl
System.Security.Claims
System.Security.Cryptography
System.Security.Cryptography.X509Certificates
System.Security.Permissions
System.Security.Policy
System.Security.Principal
System.Text
System.Threading
AutoResetEventTest.cs
CancellationTokenSourceTest.cs
CancellationTokenTests.cs
ChangeLog
CompressedStackCas.cs
CompressedStackTest.cs
CountdownEventTests.cs
EventWaitHandleTest.cs
ExecutionContextCas.cs
ExecutionContextTest.cs
InterlockedTest.cs
LazyInitializerTest.cs
ManualResetEventSlimTests.cs
MonitorTest.cs
MutexCas.cs
MutexTest.cs
ReaderWriterLockTest.cs
SemaphoreSlimTests.cs
SpinLockTests.cs
ThreadCas.cs
ThreadLocalTests.cs
ThreadPoolTest.cs
ThreadTest.cs
TimerTest.cs
VolatileTest.cs
WaitHandleCas.cs
WaitHandleTest.cs
System.Threading.Tasks
resources
coreclr
resources
ChangeLog
Makefile
corlib.dll.sources
corlib_test.dll.sources
monotouch_corlib.dll.sources
monotouch_runtime_corlib.dll.sources
monotouch_tv_corlib.dll.sources
monotouch_tv_runtime_corlib.dll.sources
monotouch_watch_corlib.dll.sources
monotouch_watch_runtime_corlib.dll.sources
net_4_x_corlib.dll.sources
xammac_corlib.dll.sources
dlr
doc
lib
monodoc
notes
reference-assemblies
test-helpers
ChangeLog
LICENSE
Makefile
README
ecma.pub
mono.pub
mono.snk
msfinal.pub
reactive.pub
silverlight.pub
winfx.pub
winfx3.pub
docs
errors
ilasm
jay
mcs
nunit24
tests
tools
AUTHORS
COPYING
COPYING.LIB
ChangeLog
INSTALL.txt
LICENSE
LICENSE.GPL
LICENSE.LGPL
LICENSE.MPL
MIT.X11
Makefile
MonoIcon.png
README
ScalableMonoIcon.svg
mkinstalldirs
winexe.in
mono
msvc
po
runtime
samples
scripts
support
tools
COPYING.LIB
ChangeLog.REMOVED.git-id
LICENSE
Makefile.am
Makefile.in
NEWS
README.md
acinclude.m4
aclocal.m4
autogen.sh
code_of_conduct.md
compile
config.guess
config.h.in
config.rpath
config.sub
configure.REMOVED.git-id
configure.ac.REMOVED.git-id
depcomp
install-sh
ltmain.sh.REMOVED.git-id
missing
mkinstalldirs
mono-uninstalled.pc.in
test-driver
winconfig.h
117 lines
3.5 KiB
C#
117 lines
3.5 KiB
C#
![]() |
//
|
||
|
// AutoResetEventTest.cs - NUnit test cases for System.Threading.AutoResetEvent
|
||
|
//
|
||
|
// Author:
|
||
|
// Gonzalo Paniagua Javier (gonzalo@ximian.com)
|
||
|
// Gert Driesen <gert.driesen@telenet.be>
|
||
|
//
|
||
|
// Copyright 2005 Novell, Inc (http://www.novell.com)
|
||
|
// Copyright 2007 Gert Driesen
|
||
|
//
|
||
|
|
||
|
using NUnit.Framework;
|
||
|
using System;
|
||
|
using System.Threading;
|
||
|
using Microsoft.Win32.SafeHandles;
|
||
|
|
||
|
namespace MonoTests.System.Threading
|
||
|
{
|
||
|
[TestFixture]
|
||
|
public class AutoResetEventTest
|
||
|
{
|
||
|
[Test]
|
||
|
public void MultipleSet ()
|
||
|
{
|
||
|
AutoResetEvent evt = new AutoResetEvent (true);
|
||
|
Assert.IsTrue (evt.WaitOne (1000, false), "#1");
|
||
|
evt.Set ();
|
||
|
evt.Set ();
|
||
|
Assert.IsTrue (evt.WaitOne (1000, false), "#2");
|
||
|
Assert.IsFalse (evt.WaitOne (1000, false), "#3");
|
||
|
}
|
||
|
|
||
|
[Test] // bug #81529
|
||
|
public void SafeWaitHandle ()
|
||
|
{
|
||
|
AutoResetEvent are1 = new AutoResetEvent (false);
|
||
|
AutoResetEvent are2 = new AutoResetEvent (false);
|
||
|
SafeWaitHandle swh1 = are1.SafeWaitHandle;
|
||
|
SafeWaitHandle swh2 = are2.SafeWaitHandle;
|
||
|
are1.SafeWaitHandle = are2.SafeWaitHandle;
|
||
|
Assert.AreSame (are1.SafeWaitHandle, are2.SafeWaitHandle, "#1");
|
||
|
Assert.AreEqual (are1.Handle, are2.Handle, "#2");
|
||
|
Assert.IsFalse (are1.SafeWaitHandle.IsInvalid, "#3");
|
||
|
Assert.IsFalse (are1.SafeWaitHandle.IsClosed, "#4");
|
||
|
Assert.IsFalse (swh1.IsClosed, "#5");
|
||
|
Assert.IsFalse (swh1.IsInvalid, "#6");
|
||
|
swh1.Dispose ();
|
||
|
are1.Close ();
|
||
|
}
|
||
|
|
||
|
[Test] // bug #81529
|
||
|
public void SafeWaitHandle_Null ()
|
||
|
{
|
||
|
AutoResetEvent are1 = new AutoResetEvent (false);
|
||
|
SafeWaitHandle swh1 = are1.SafeWaitHandle;
|
||
|
are1.SafeWaitHandle = null;
|
||
|
Assert.IsNotNull (are1.SafeWaitHandle, "#1");
|
||
|
Assert.AreEqual (-1, (int) are1.Handle, "#2");
|
||
|
Assert.IsTrue (are1.SafeWaitHandle.IsInvalid, "#3");
|
||
|
Assert.IsFalse (are1.SafeWaitHandle.IsClosed, "#4");
|
||
|
Assert.IsFalse (swh1.IsClosed, "#5");
|
||
|
Assert.IsFalse (swh1.IsInvalid, "#6");
|
||
|
}
|
||
|
|
||
|
[Test] // bug #81529
|
||
|
// Causes a Attempting to unref unused handle 0x2 warning
|
||
|
[Category ("NotWorking")]
|
||
|
public void Handle_Valid ()
|
||
|
{
|
||
|
AutoResetEvent are1 = new AutoResetEvent (false);
|
||
|
SafeWaitHandle swh1 = are1.SafeWaitHandle;
|
||
|
Assert.IsFalse (swh1.IsClosed, "#1");
|
||
|
Assert.IsFalse (swh1.IsInvalid, "#2");
|
||
|
IntPtr dummyHandle = (IntPtr) 2;
|
||
|
are1.Handle = dummyHandle;
|
||
|
Assert.AreEqual (are1.Handle, dummyHandle, "#3");
|
||
|
Assert.IsFalse (swh1.IsClosed, "#4");
|
||
|
Assert.IsFalse (swh1.IsClosed, "#5");
|
||
|
Assert.IsFalse (swh1.IsInvalid, "#6");
|
||
|
Assert.IsFalse (are1.SafeWaitHandle.IsClosed, "#7");
|
||
|
Assert.IsFalse (are1.SafeWaitHandle.IsInvalid, "#8");
|
||
|
are1.Close ();
|
||
|
swh1.Dispose ();
|
||
|
}
|
||
|
|
||
|
[Test] // bug #81529
|
||
|
public void Handle_Invalid ()
|
||
|
{
|
||
|
AutoResetEvent are1 = new AutoResetEvent (false);
|
||
|
SafeWaitHandle swh1 = are1.SafeWaitHandle;
|
||
|
are1.Handle = (IntPtr) (-1);
|
||
|
Assert.IsTrue (swh1 != are1.SafeWaitHandle, "#1");
|
||
|
Assert.IsFalse (swh1.IsClosed, "#2");
|
||
|
Assert.IsFalse (swh1.IsInvalid, "#3");
|
||
|
Assert.IsFalse (are1.SafeWaitHandle.IsClosed, "#4");
|
||
|
Assert.IsTrue (are1.SafeWaitHandle.IsInvalid, "#5");
|
||
|
are1.Close ();
|
||
|
swh1.Dispose ();
|
||
|
}
|
||
|
|
||
|
[Test] // bug #81529
|
||
|
public void Handle_ZeroPtr ()
|
||
|
{
|
||
|
AutoResetEvent are1 = new AutoResetEvent (false);
|
||
|
SafeWaitHandle swh1 = are1.SafeWaitHandle;
|
||
|
are1.Handle = IntPtr.Zero;
|
||
|
Assert.IsTrue (swh1 != are1.SafeWaitHandle, "#1");
|
||
|
Assert.IsFalse (swh1.IsClosed, "#2");
|
||
|
Assert.IsFalse (swh1.IsInvalid, "#3");
|
||
|
Assert.IsFalse (are1.SafeWaitHandle.IsClosed, "#4");
|
||
|
Assert.IsTrue (are1.SafeWaitHandle.IsInvalid, "#5");
|
||
|
are1.Close ();
|
||
|
swh1.Dispose ();
|
||
|
}
|
||
|
}
|
||
|
}
|