Click here to Skip to main content
15,893,722 members
Articles / Desktop Programming / Windows Forms

Getting Around InvokeRequired Without Copy and Paste

Rate me:
Please Sign up or sign in to vote.
4.93/5 (14 votes)
17 Aug 20072 min read 121.6K   749   53  
Instead of copying and pasting the same if(InvokeRequired) logic in every multithreaded function, use attributes to make code cleaner, its centralize logic and make it self documenting.

Microsoft Visual Studio Solution File, Format Version 9.00
# Visual Studio 2005
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ThreadSafeUI", "ThreadSafeUI\ThreadSafeUI.csproj", "{3501626F-FC59-46AD-8989-24BC558CCAC8}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TeamAgile.SimpleInterception", "TeamAgile.SimpleInterception\TeamAgile.SimpleInterception.csproj", "{5426283C-C78B-4AEF-A305-325D4A1DCA74}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Test", "Test\Test.csproj", "{EDA73BDA-998E-4463-A120-172F1A214DC6}"
EndProject
Global
	GlobalSection(SolutionConfigurationPlatforms) = preSolution
		Debug|Any CPU = Debug|Any CPU
		Release|Any CPU = Release|Any CPU
	EndGlobalSection
	GlobalSection(ProjectConfigurationPlatforms) = postSolution
		{3501626F-FC59-46AD-8989-24BC558CCAC8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
		{3501626F-FC59-46AD-8989-24BC558CCAC8}.Debug|Any CPU.Build.0 = Debug|Any CPU
		{3501626F-FC59-46AD-8989-24BC558CCAC8}.Release|Any CPU.ActiveCfg = Release|Any CPU
		{3501626F-FC59-46AD-8989-24BC558CCAC8}.Release|Any CPU.Build.0 = Release|Any CPU
		{5426283C-C78B-4AEF-A305-325D4A1DCA74}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
		{5426283C-C78B-4AEF-A305-325D4A1DCA74}.Debug|Any CPU.Build.0 = Debug|Any CPU
		{5426283C-C78B-4AEF-A305-325D4A1DCA74}.Release|Any CPU.ActiveCfg = Release|Any CPU
		{5426283C-C78B-4AEF-A305-325D4A1DCA74}.Release|Any CPU.Build.0 = Release|Any CPU
		{EDA73BDA-998E-4463-A120-172F1A214DC6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
		{EDA73BDA-998E-4463-A120-172F1A214DC6}.Debug|Any CPU.Build.0 = Debug|Any CPU
		{EDA73BDA-998E-4463-A120-172F1A214DC6}.Release|Any CPU.ActiveCfg = Release|Any CPU
		{EDA73BDA-998E-4463-A120-172F1A214DC6}.Release|Any CPU.Build.0 = Release|Any CPU
	EndGlobalSection
	GlobalSection(SolutionProperties) = preSolution
		HideSolutionNode = FALSE
	EndGlobalSection
EndGlobal

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
United States United States
I've been a software developer since 1996 and have enjoyed C# since 2003. I have a Bachelor's degree in Computer Science and for some reason, a Master's degree in Business Administration. I currently do software development contracting/consulting.

Comments and Discussions