Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?xml version="1.0" encoding="utf-8" ?>
- <CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
- <CodeSnippet Format="1.0.0">
- <Header>
- <Title>AH WriteOutput</Title>
- <Shortcut>ahWriteOutput</Shortcut>
- <Description>Code snippet created on: 2/23/2011 5:29:10 PM</Description>
- <Author>Andrew Hodgson</Author>
- <SnippetTypes>
- <SnippetType>Expansion</SnippetType>
- </SnippetTypes>
- </Header>
- <Snippet>
- <Declarations>
- <Literal>
- <ID>type</ID>
- <ToolTip>Property type</ToolTip>
- <Default>string</Default>
- </Literal>
- <Literal>
- <ID>property</ID>
- <ToolTip>Property name</ToolTip>
- <Default>MyProperty</Default>
- </Literal>
- </Declarations>
- <Code Language="csharp">
- <![CDATA[ void WriteOutput(string format,params object[] args) {
- WriteOutput(string.Format(format,args));
- }
- /// <summary>
- /// Writes output to a windows form using InvokeRequired property
- /// </summary>
- /// <param name="value">Data to output</param>
- void WriteOutput(object value) {
- string text = value == null ? string.Empty : value.ToString();
- text += Environment.NewLine;
- Action<string> writeAction = (s) => richTextBox1.AppendText(s);
- if(InvokeRequired)
- BeginInvoke(new Action<string>(writeAction),text);
- else
- writeAction(text);
- }$end$]]>
- </Code>
- </Snippet>
- </CodeSnippet>
- </CodeSnippets>
Advertisement
Add Comment
Please, Sign In to add comment