[1146] | 1 | <!-- saved from url=(0014)about:internet --><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN">
|
---|
| 2 | <html>
|
---|
| 3 | <!-- Standard Head Part -->
|
---|
| 4 | <head>
|
---|
| 5 | <title>NUnit - RequiresSTA</title>
|
---|
| 6 | <meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
|
---|
| 7 | <meta http-equiv="Content-Language" content="en-US">
|
---|
| 8 | <link rel="stylesheet" type="text/css" href="nunit.css">
|
---|
| 9 | <link rel="shortcut icon" href="favicon.ico">
|
---|
| 10 | </head>
|
---|
| 11 | <!-- End Standard Head Part -->
|
---|
| 12 |
|
---|
| 13 | <body>
|
---|
| 14 |
|
---|
| 15 | <!-- Standard Header for NUnit.org -->
|
---|
| 16 | <div id="header">
|
---|
| 17 | <a id="logo" href="http://www.nunit.org"><img src="img/logo.gif" alt="NUnit.org" title="NUnit.org"></a>
|
---|
| 18 | <div id="nav">
|
---|
| 19 | <a href="http://www.nunit.org">NUnit</a>
|
---|
| 20 | <a class="active" href="index.html">Documentation</a>
|
---|
| 21 | </div>
|
---|
| 22 | </div>
|
---|
| 23 | <!-- End of Header -->
|
---|
| 24 |
|
---|
| 25 | <div id="content">
|
---|
| 26 |
|
---|
| 27 | <h3>RequiresSTAAttribute (NUnit 2.5)</h3>
|
---|
| 28 |
|
---|
| 29 | <p>The <b>RequiresSTAAttribute</b> is used on a test method, class or assembly
|
---|
| 30 | to specify that the tests should be run in the Single-threaded apartment.
|
---|
| 31 | It causes creation of a new thread if the parent test is not already running
|
---|
| 32 | in the STA.
|
---|
| 33 |
|
---|
| 34 | <p><b>Note:</b> On test methods, you may also use the <b>STAThreadAttribute</b>.
|
---|
| 35 | Although the runtime only recognizes this attribute on the entrypoint of
|
---|
| 36 | an executable assembly, many users have expected it to work on tests, so
|
---|
| 37 | we treat it as a synonym.
|
---|
| 38 |
|
---|
| 39 | <h4>Examples</h4>
|
---|
| 40 |
|
---|
| 41 | <div class="code">
|
---|
| 42 |
|
---|
| 43 | <pre>
|
---|
| 44 |
|
---|
| 45 | // An STA thread will be created and used to run
|
---|
| 46 | // all the tests in the assembly
|
---|
| 47 | [assembly:RequiresSTA]
|
---|
| 48 |
|
---|
| 49 | ...
|
---|
| 50 |
|
---|
| 51 | // TestFixture requiring a separate thread
|
---|
| 52 | [TestFixture, RequiresSTA]
|
---|
| 53 | public class FixtureRequiringSTA
|
---|
| 54 | {
|
---|
| 55 | // An STA thread will be created and all
|
---|
| 56 | // tests in the fixture will run on it
|
---|
| 57 | // unless the containing assembly is
|
---|
| 58 | // already running on an STA Thread
|
---|
| 59 | }
|
---|
| 60 |
|
---|
| 61 | [TestFixture]
|
---|
| 62 | public class AnotherFixture
|
---|
| 63 | {
|
---|
| 64 | [Test, RequiresSTA]
|
---|
| 65 | public void TestRequiringSTA()
|
---|
| 66 | {
|
---|
| 67 | // A separate thread will be created for this test
|
---|
| 68 | // unless the containing fixture is already running
|
---|
| 69 | // in the STA.
|
---|
| 70 | }
|
---|
| 71 | }
|
---|
| 72 |
|
---|
| 73 | </pre>
|
---|
| 74 |
|
---|
| 75 | </div>
|
---|
| 76 |
|
---|
| 77 | <h4>See also...</h4>
|
---|
| 78 | <ul>
|
---|
| 79 | <li><a href="requiresThread.html">RequiresThreadAttribute</a><li><a href="requiresMTA.html">RequiresMTAAttribute</a></ul>
|
---|
| 80 |
|
---|
| 81 |
|
---|
| 82 | </div>
|
---|
| 83 |
|
---|
| 84 | <!-- Submenu -->
|
---|
| 85 | <div id="subnav">
|
---|
| 86 | <ul>
|
---|
| 87 | <li><a href="index.html">NUnit 2.5.10</a></li>
|
---|
| 88 | <ul>
|
---|
| 89 | <li><a href="getStarted.html">Getting Started</a></li>
|
---|
| 90 | <li><a href="assertions.html">Assertions</a></li>
|
---|
| 91 | <li><a href="constraintModel.html">Constraints</a></li>
|
---|
| 92 | <li><a href="attributes.html">Attributes</a></li>
|
---|
| 93 | <ul>
|
---|
| 94 | <li><a href="category.html">Category</a></li>
|
---|
| 95 | <li><a href="combinatorial.html">Combinatorial</a></li>
|
---|
| 96 | <li><a href="culture.html">Culture</a></li>
|
---|
| 97 | <li><a href="datapoint.html">Datapoint(s)</a></li>
|
---|
| 98 | <li><a href="description.html">Description</a></li>
|
---|
| 99 | <li><a href="exception.html">Exception</a></li>
|
---|
| 100 | <li><a href="explicit.html">Explicit</a></li>
|
---|
| 101 | <li><a href="ignore.html">Ignore</a></li>
|
---|
| 102 | <li><a href="maxtime.html">Maxtime</a></li>
|
---|
| 103 | <li><a href="pairwise.html">Pairwise</a></li>
|
---|
| 104 | <li><a href="platform.html">Platform</a></li>
|
---|
| 105 | <li><a href="property.html">Property</a></li>
|
---|
| 106 | <li><a href="random.html">Random</a></li>
|
---|
| 107 | <li><a href="range.html">Range</a></li>
|
---|
| 108 | <li><a href="repeat.html">Repeat</a></li>
|
---|
| 109 | <li><a href="requiredAddin.html">RequiredAddin</a></li>
|
---|
| 110 | <li><a href="requiresMTA.html">Requires MTA</a></li>
|
---|
| 111 | <li id="current"><a href="requiresSTA.html">Requires STA</a></li>
|
---|
| 112 | <li><a href="requiresThread.html">Requires Thread</a></li>
|
---|
| 113 | <li><a href="sequential.html">Sequential</a></li>
|
---|
| 114 | <li><a href="setCulture.html">SetCulture</a></li>
|
---|
| 115 | <li><a href="setUICulture.html">SetUICulture</a></li>
|
---|
| 116 | <li><a href="setup.html">Setup</a></li>
|
---|
| 117 | <li><a href="setupFixture.html">SetupFixture</a></li>
|
---|
| 118 | <li><a href="suite.html">Suite</a></li>
|
---|
| 119 | <li><a href="teardown.html">Teardown</a></li>
|
---|
| 120 | <li><a href="test.html">Test</a></li>
|
---|
| 121 | <li><a href="testCase.html">TestCase</a></li>
|
---|
| 122 | <li><a href="testCaseSource.html">TestCaseSource</a></li>
|
---|
| 123 | <li><a href="testFixture.html">TestFixture</a></li>
|
---|
| 124 | <li><a href="fixtureSetup.html">TestFixtureSetUp</a></li>
|
---|
| 125 | <li><a href="fixtureTeardown.html">TestFixtureTearDown</a></li>
|
---|
| 126 | <li><a href="theory.html">Theory</a></li>
|
---|
| 127 | <li><a href="timeout.html">Timeout</a></li>
|
---|
| 128 | <li><a href="values.html">Values</a></li>
|
---|
| 129 | <li><a href="valueSource.html">ValueSource</a></li>
|
---|
| 130 | </ul>
|
---|
| 131 | <li><a href="runningTests.html">Running Tests</a></li>
|
---|
| 132 | <li><a href="extensibility.html">Extensibility</a></li>
|
---|
| 133 | <li><a href="releaseNotes.html">Release Notes</a></li>
|
---|
| 134 | <li><a href="samples.html">Samples</a></li>
|
---|
| 135 | <li><a href="license.html">License</a></li>
|
---|
| 136 | </ul>
|
---|
| 137 | </ul>
|
---|
| 138 | </div>
|
---|
| 139 | <!-- End of Submenu -->
|
---|
| 140 |
|
---|
| 141 |
|
---|
| 142 | <!-- Standard Footer for NUnit.org -->
|
---|
| 143 | <div id="footer">
|
---|
| 144 | Copyright © 2010 Charlie Poole. All Rights Reserved.
|
---|
| 145 | </div>
|
---|
| 146 | <!-- End of Footer -->
|
---|
| 147 |
|
---|
| 148 | </body>
|
---|
| 149 | </html>
|
---|