| <html><head><meta http-equiv="X-UA-Compatible" content="IE=edge" /><link rel="shortcut icon" href="../icons/favicon.ico" /><link rel="stylesheet" type="text/css" href="../styles/branding.css" /><link rel="stylesheet" type="text/css" href="../styles/branding-en-US.css" /><script type="text/javascript" src="../scripts/branding.js"> </script><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>AsyncStreamExtensions.ForEachAsync(T) Method </title><meta name="Language" content="en-us" /><meta name="System.Keywords" content="ForEachAsync%3CT%3E method" /><meta name="System.Keywords" content="ForEachAsync(Of T) method" /><meta name="System.Keywords" content="AsyncStreamExtensions.ForEachAsync%3CT%3E method" /><meta name="System.Keywords" content="AsyncStreamExtensions.ForEachAsync(Of T) method" /><meta name="Microsoft.Help.F1" content="Grpc.Core.Utils.AsyncStreamExtensions.ForEachAsync``1" /><meta name="Microsoft.Help.Id" content="M:Grpc.Core.Utils.AsyncStreamExtensions.ForEachAsync``1(Grpc.Core.IAsyncStreamReader{``0},System.Func{``0,System.Threading.Tasks.Task})" /><meta name="Description" content="Reads the entire stream and executes an async action for each element." /><meta name="Microsoft.Help.ContentType" content="Reference" /><meta name="BrandingAware" content="true" /><meta name="container" content="Grpc.Core.Utils" /><meta name="file" content="M_Grpc_Core_Utils_AsyncStreamExtensions_ForEachAsync__1" /><meta name="guid" content="M_Grpc_Core_Utils_AsyncStreamExtensions_ForEachAsync__1" /><link rel="stylesheet" type="text/css" href="../styles/branding-Website.css" /><script type="text/javascript" src="../scripts/jquery-1.11.0.min.js"></script><script type="text/javascript" src="../scripts/branding-Website.js"></script></head><body onload="OnLoad('cs')"><input type="hidden" id="userDataCache" class="userDataStyle" /><div class="pageHeader" id="PageHeader">gRPC C#<form id="SearchForm" method="get" action="#" onsubmit="javascript:TransferToSearchPage(); return false;"><input id="SearchTextBox" type="text" maxlength="200" /><button id="SearchButton" type="submit"></button></form></div><div class="pageBody"><div class="leftNav" id="leftNav"><div id="tocNav"><div class="toclevel0" data-toclevel="0"><a class="tocCollapsed" onclick="javascript: Toggle(this);" href="#!" /><a data-tochassubtree="true" href="R_Project_Documentation.htm" title="gRPC C#" tocid="roottoc">gRPC C#</a></div><div class="toclevel0" data-toclevel="0"><a class="tocCollapsed" onclick="javascript: Toggle(this);" href="#!" /><a data-tochassubtree="true" href="R_Project_Documentation.htm" title="Namespaces" tocid="R_Project_Documentation">Namespaces</a></div><div class="toclevel0" data-toclevel="0"><a class="tocCollapsed" onclick="javascript: Toggle(this);" href="#!" /><a data-tochassubtree="true" href="N_Grpc_Core_Utils.htm" title="Grpc.Core.Utils" tocid="N_Grpc_Core_Utils">Grpc.Core.Utils</a></div><div class="toclevel0" data-toclevel="0"><a class="tocCollapsed" onclick="javascript: Toggle(this);" href="#!" /><a data-tochassubtree="true" href="T_Grpc_Core_Utils_AsyncStreamExtensions.htm" title="AsyncStreamExtensions Class" tocid="T_Grpc_Core_Utils_AsyncStreamExtensions">AsyncStreamExtensions Class</a></div><div class="toclevel1" data-toclevel="1" data-childrenloaded="true"><a class="tocExpanded" onclick="javascript: Toggle(this);" href="#!" /><a data-tochassubtree="true" href="Methods_T_Grpc_Core_Utils_AsyncStreamExtensions.htm" title="AsyncStreamExtensions Methods" tocid="Methods_T_Grpc_Core_Utils_AsyncStreamExtensions">AsyncStreamExtensions Methods</a></div><div class="toclevel2 current" data-toclevel="2"><a data-tochassubtree="false" href="M_Grpc_Core_Utils_AsyncStreamExtensions_ForEachAsync__1.htm" title="ForEachAsync(T) Method " tocid="M_Grpc_Core_Utils_AsyncStreamExtensions_ForEachAsync__1">ForEachAsync(T) Method </a></div><div class="toclevel2" data-toclevel="2"><a data-tochassubtree="false" href="M_Grpc_Core_Utils_AsyncStreamExtensions_ToListAsync__1.htm" title="ToListAsync(T) Method " tocid="M_Grpc_Core_Utils_AsyncStreamExtensions_ToListAsync__1">ToListAsync(T) Method </a></div><div class="toclevel2" data-toclevel="2"><a class="tocCollapsed" onclick="javascript: Toggle(this);" href="#!" /><a data-tochassubtree="true" href="Overload_Grpc_Core_Utils_AsyncStreamExtensions_WriteAllAsync.htm" title="WriteAllAsync Method " tocid="Overload_Grpc_Core_Utils_AsyncStreamExtensions_WriteAllAsync">WriteAllAsync Method </a></div></div><div id="tocResizableEW" onmousedown="OnMouseDown(event);"></div><div id="TocResize" class="tocResize"><img id="ResizeImageIncrease" src="../icons/TocOpen.gif" onclick="OnIncreaseToc()" alt="Click or drag to resize" title="Click or drag to resize" /><img id="ResizeImageReset" src="../icons/TocClose.gif" style="display:none" onclick="OnResetToc()" alt="Click or drag to resize" title="Click or drag to resize" /></div></div><div class="topicContent" id="TopicContent"><table class="titleTable"><tr><td class="titleColumn">AsyncStreamExtensions<span id="LST91555AB7_0"></span><script type="text/javascript">AddLanguageSpecificTextSet("LST91555AB7_0?cpp=::|nu=.");</script>ForEachAsync<span id="LST91555AB7_1"></span><script type="text/javascript">AddLanguageSpecificTextSet("LST91555AB7_1?cs=<|vb=(Of |cpp=<|fs=<'|nu=(");</script><span class="typeparameter">T</span><span id="LST91555AB7_2"></span><script type="text/javascript">AddLanguageSpecificTextSet("LST91555AB7_2?cs=>|vb=)|cpp=>|fs=>|nu=)");</script> Method </td></tr></table><span class="introStyle"></span><div class="summary"> |
| Reads the entire stream and executes an async action for each element. |
| </div><p> </p><strong>Namespace:</strong> <a href="N_Grpc_Core_Utils.htm">Grpc.Core.Utils</a><br /><strong>Assembly:</strong> Grpc.Core (in Grpc.Core.dll) Version: 0.6.1.0<div class="collapsibleAreaRegion"><span class="collapsibleRegionTitle" onclick="SectionExpandCollapse('ID1RB')" onkeypress="SectionExpandCollapse_CheckKey('ID1RB', event)" tabindex="0"><img id="ID1RBToggle" class="collapseToggle" src="../icons/SectionExpanded.png" />Syntax</span></div><div id="ID1RBSection" class="collapsibleSection"><div class="codeSnippetContainer"><div class="codeSnippetContainerTabs"><div id="ID0EDCA_tab1" class="codeSnippetContainerTab"><a href="#" onclick="javascript:ChangeTab('ID0EDCA','cs','1','4');return false;">C#</a></div><div id="ID0EDCA_tab2" class="codeSnippetContainerTab"><a href="#" onclick="javascript:ChangeTab('ID0EDCA','vb','2','4');return false;">VB</a></div><div id="ID0EDCA_tab3" class="codeSnippetContainerTab"><a href="#" onclick="javascript:ChangeTab('ID0EDCA','cpp','3','4');return false;">C++</a></div><div id="ID0EDCA_tab4" class="codeSnippetContainerTab"><a href="#" onclick="javascript:ChangeTab('ID0EDCA','fs','4','4');return false;">F#</a></div></div><div class="codeSnippetContainerCodeContainer"><div class="codeSnippetToolBar"><div class="codeSnippetToolBarText"><a id="ID0EDCA_copyCode" href="#" onclick="javascript:CopyToClipboard('ID0EDCA');return false;" title="Copy">Copy</a></div></div><div id="ID0EDCA_code_Div1" class="codeSnippetContainerCode" style="display: block"><pre xml:space="preserve"><span class="keyword">public</span> <span class="keyword">static</span> <span class="identifier">Task</span> <span class="identifier">ForEachAsync</span><T>( |
| <span class="keyword">this</span> <span class="identifier">IAsyncStreamReader</span><T> <span class="parameter">streamReader</span>, |
| <span class="identifier">Func</span><T, <span class="identifier">Task</span>> <span class="parameter">asyncAction</span> |
| ) |
| <span class="keyword">where</span> T : <span class="keyword">class</span> |
| </pre></div><div id="ID0EDCA_code_Div2" class="codeSnippetContainerCode" style="display: none"><pre xml:space="preserve"><<span class="identifier">ExtensionAttribute</span>> |
| <span class="keyword">Public</span> <span class="keyword">Shared</span> <span class="keyword">Function</span> <span class="identifier">ForEachAsync</span>(<span class="keyword">Of</span> T <span class="keyword">As</span> <span class="keyword">Class</span>) ( |
| <span class="parameter">streamReader</span> <span class="keyword">As</span> <span class="identifier">IAsyncStreamReader</span>(<span class="keyword">Of</span> T), |
| <span class="parameter">asyncAction</span> <span class="keyword">As</span> <span class="identifier">Func</span>(<span class="keyword">Of</span> T, <span class="identifier">Task</span>) |
| ) <span class="keyword">As</span> <span class="identifier">Task</span></pre></div><div id="ID0EDCA_code_Div3" class="codeSnippetContainerCode" style="display: none"><pre xml:space="preserve"><span class="keyword">public</span>: |
| [<span class="identifier">ExtensionAttribute</span>] |
| <span class="keyword">generic</span><<span class="keyword">typename</span> T> |
| <span class="keyword">where</span> T : <span class="keyword">ref class</span> |
| <span class="keyword">static</span> <span class="identifier">Task</span>^ <span class="identifier">ForEachAsync</span>( |
| <span class="identifier">IAsyncStreamReader</span><T>^ <span class="parameter">streamReader</span>, |
| <span class="identifier">Func</span><T, <span class="identifier">Task</span>^>^ <span class="parameter">asyncAction</span> |
| )</pre></div><div id="ID0EDCA_code_Div4" class="codeSnippetContainerCode" style="display: none"><pre xml:space="preserve">[<<span class="identifier">ExtensionAttribute</span>>] |
| <span class="keyword">static</span> <span class="keyword">member</span> <span class="identifier">ForEachAsync</span> : |
| <span class="parameter">streamReader</span> : <span class="identifier">IAsyncStreamReader</span><'T> * |
| <span class="parameter">asyncAction</span> : <span class="identifier">Func</span><'T, <span class="identifier">Task</span>> <span class="keyword">-></span> <span class="identifier">Task</span> <span class="keyword">when</span> 'T : <span class="keyword">not struct</span> |
| </pre></div></div></div><script type="text/javascript">AddLanguageTabSet("ID0EDCA");</script><h4 class="subHeading">Parameters</h4><dl><dt><span class="parameter">streamReader</span></dt><dd>Type: <a href="T_Grpc_Core_IAsyncStreamReader_1.htm">Grpc.Core<span id="LST91555AB7_3"></span><script type="text/javascript">AddLanguageSpecificTextSet("LST91555AB7_3?cs=.|vb=.|cpp=::|nu=.|fs=.");</script>IAsyncStreamReader</a><span id="LST91555AB7_4"></span><script type="text/javascript">AddLanguageSpecificTextSet("LST91555AB7_4?cs=<|vb=(Of |cpp=<|fs=<'|nu=(");</script><span class="selflink"><span class="typeparameter">T</span></span><span id="LST91555AB7_5"></span><script type="text/javascript">AddLanguageSpecificTextSet("LST91555AB7_5?cs=>|vb=)|cpp=>|fs=>|nu=)");</script><br /><p style="color: #dc143c; font-size: 8.5pt; font-weight: bold;">[Missing <param name="streamReader"/> documentation for "M:Grpc.Core.Utils.AsyncStreamExtensions.ForEachAsync``1(Grpc.Core.IAsyncStreamReader{``0},System.Func{``0,System.Threading.Tasks.Task})"]</p></dd><dt><span class="parameter">asyncAction</span></dt><dd>Type: <a href="http://msdn2.microsoft.com/en-us/library/bb549151" target="_blank">System<span id="LST91555AB7_6"></span><script type="text/javascript">AddLanguageSpecificTextSet("LST91555AB7_6?cs=.|vb=.|cpp=::|nu=.|fs=.");</script>Func</a><span id="LST91555AB7_7"></span><script type="text/javascript">AddLanguageSpecificTextSet("LST91555AB7_7?cs=<|vb=(Of |cpp=<|fs=<'|nu=(");</script><span class="selflink"><span class="typeparameter">T</span></span>, <a href="http://msdn2.microsoft.com/en-us/library/dd235678" target="_blank">Task</a><span id="LST91555AB7_8"></span><script type="text/javascript">AddLanguageSpecificTextSet("LST91555AB7_8?cs=>|vb=)|cpp=>|fs=>|nu=)");</script><br /><p style="color: #dc143c; font-size: 8.5pt; font-weight: bold;">[Missing <param name="asyncAction"/> documentation for "M:Grpc.Core.Utils.AsyncStreamExtensions.ForEachAsync``1(Grpc.Core.IAsyncStreamReader{``0},System.Func{``0,System.Threading.Tasks.Task})"]</p></dd></dl><h4 class="subHeading">Type Parameters</h4><dl><dt><span class="parameter">T</span></dt><dd><p style="color: #dc143c; font-size: 8.5pt; font-weight: bold;">[Missing <typeparam name="T"/> documentation for "M:Grpc.Core.Utils.AsyncStreamExtensions.ForEachAsync``1(Grpc.Core.IAsyncStreamReader{``0},System.Func{``0,System.Threading.Tasks.Task})"]</p></dd></dl><h4 class="subHeading">Return Value</h4>Type: <a href="http://msdn2.microsoft.com/en-us/library/dd235678" target="_blank">Task</a><h4 class="subHeading">Usage Note</h4>In Visual Basic and C#, you can call this method as an instance method on any object of type <a href="T_Grpc_Core_IAsyncStreamReader_1.htm">IAsyncStreamReader</a><span id="LST91555AB7_9"></span><script type="text/javascript">AddLanguageSpecificTextSet("LST91555AB7_9?cs=<|vb=(Of |cpp=<|fs=<'|nu=(");</script><span class="selflink"><span class="typeparameter">T</span></span><span id="LST91555AB7_10"></span><script type="text/javascript">AddLanguageSpecificTextSet("LST91555AB7_10?cs=>|vb=)|cpp=>|fs=>|nu=)");</script>. When you use instance method syntax to call this method, omit the first parameter. For more information, see <a href="http://msdn.microsoft.com/en-us/library/bb384936.aspx" target="_blank">Extension Methods (Visual Basic)</a> or <a href="http://msdn.microsoft.com/en-us/library/bb383977.aspx" target="_blank">Extension Methods (C# Programming Guide)</a>.</div><div class="collapsibleAreaRegion" id="seeAlsoSection"><span class="collapsibleRegionTitle" onclick="SectionExpandCollapse('ID2RB')" onkeypress="SectionExpandCollapse_CheckKey('ID2RB', event)" tabindex="0"><img id="ID2RBToggle" class="collapseToggle" src="../icons/SectionExpanded.png" />See Also</span></div><div id="ID2RBSection" class="collapsibleSection"><h4 class="subHeading">Reference</h4><div class="seeAlsoStyle"><a href="T_Grpc_Core_Utils_AsyncStreamExtensions.htm">AsyncStreamExtensions Class</a></div><div class="seeAlsoStyle"><a href="N_Grpc_Core_Utils.htm">Grpc.Core.Utils Namespace</a></div></div></div></div><div id="pageFooter" class="pageFooter"> </div></body></html> |