EndInvoke
.NET System.Delegate BeginInvoke 메서드로 시작된 비동기 호출(Asynchronous Call)의 결과 검색
설명
는 Microsoft® .NET Framework 애플리케이션에 대해 result
= EndInvoke(asyncResult
)BeginInvoke
메서드로 시작된 비동기 호출의 결과를 검색합니다. 동기식 메서드를 비동기식으로 호출하는 방법에 대한 내용은 Microsoft .NET 문서를 참조하십시오.
참고
.NET 5와 .NET Core 및 그 이상의 버전을 포함해 .NET Framework 4.0 이상을 사용하는 애플리케이션에서는 System.Threading.Tasks
와 같은 태스크 기반 API를 사용하십시오. 자세한 내용은 Microsoft 게시물 Task-based asynchronous pattern (TAP) in .NET을 참조하십시오.
[
는 res0,...,resN
] = EndInvoke(res0,...,resN
,asyncResult
)out
및/또는 ref
파라미터를 포함하는 메서드용입니다.
예제
반환 값이 있는 대리자(Delegate) 호출하기
del2int
대리자(Delegate)는 두 개의 입력 인수의 결과를 반환합니다. 이 대리자는 out
또는 ref
파라미터가 없습니다.
이 C# 대리자(Delegate) 코드를 SignatureExamples
라는 어셈블리에 빌드하고 MATLAB®으로 불러옵니다. 자세한 내용은 Build a .NET Application for MATLAB Examples 항목을 참조하십시오.
public delegate Int32 del2int(Int32 arg1, Int32 arg2);
두 정수를 더하는 MATLAB 함수를 만듭니다.
% Add input arguments function res = addfcn(A, B) % A and B are numbers res = A + B; end
대리자를 만들고 BeginInvoke
시그니처를 표시합니다.
myDel = SignatureExamples.del2int(@addfcn); methodsview(myDel)
System.IAsyncResult RetVal BeginInvoke ( SignatureExamples.del2int this, int32 scalar arg1, int32 scalar arg2, System.AsyncCallback callback, System.Object object)
EndInvoke
시그니처를 검토합니다.
int32 scalar RetVal EndInvoke ( SignatureExamples.del2int this, System.IAsyncResult result)
addfcn
을 호출합니다.
asyncRes = myDel.BeginInvoke(6,8,[],[]); while asyncRes.IsCompleted ~= true pause(0.05) % Use pause() to let MATLAB process event end result = myDel.EndInvoke(asyncRes)
result = 14
ref
파라미터가 있는 대리자(Delegate) 호출하기
delrefvoid
대리자(Delegate)는 ref
(refArg
) 파라미터를 사용합니다. MATLAB은 ref
인수를 RHS 인수와 LHS 인수 모두로 매핑합니다.
이 C# 대리자(Delegate) 코드를 SignatureExamples
라는 어셈블리에 빌드하고 MATLAB으로 불러옵니다.
public delegate void delrefvoid(ref Double refArg);
입력 인수를 증가시키고 그 결과를 반환하는 MATLAB 함수를 만듭니다.
% Increment input argument function res = incfcn(A) % A = number res = A + 1; end
대리자를 만들고 BeginInvoke
시그니처를 표시합니다.
myDel = SignatureExamples.delrefvoid(@incfcn); methodsview(myDel)
[System.IAsyncResult RetVal, double scalar refArg] BeginInvoke ( SignatureExamples.delrefvoid this, double scalar refArg, System.AsyncCallback callback, System.Object object)
EndInvoke
시그니처를 검토합니다.
double scalar refArg EndInvoke ( SignatureExamples.delrefvoid this, double scalar refArg, System.IAsyncResult result)
incfcn
을 호출합니다.
x = 6; asyncRes = myDel.BeginInvoke(x,[],[]); while asyncRes.IsCompleted ~= true pause(0.05) % Use pause() to let MATLAB process event end myRef = 0; result = myDel.EndInvoke(myRef,asyncRes); disp(['Increment of ' num2str(x) ' = ' num2str(result)]);
Increment of 6 = 7
out
파라미터가 있는 대리자(Delegate) 호출하기
deloutsingle
대리자(Delegate)는 out
파라미터(argOut
)와 하나의 반환 값을 사용합니다. MATLAB은 out
인수를 추가 반환 값으로 매핑합니다.
이 C# 대리자(Delegate) 코드를 SignatureExamples
라는 어셈블리에 빌드하고 MATLAB으로 불러옵니다.
public delegate Single deloutsingle(Single argIn, out Single argOut);
입력 인수를 두 배로 증가시키는 MATLAB 함수를 만듭니다.
% Double input argument function [res1,res2] = times2fcn(A) res1 = A*2; res2 = res1; end
대리자를 만들고 BeginInvoke
시그니처를 표시합니다.
myDel = SignatureExamples.deloutsingle(@times2fcn); methodsview(myDel)
[System.IAsyncResult RetVal, single scalar argOut] BeginInvoke ( SignatureExamples.deloutsingle this, single scalar argIn, System.AsyncCallback callback, System.Object object)
EndInvoke
시그니처를 검토합니다.
[single scalar RetVal, single scalar argOut] EndInvoke ( SignatureExamples.deloutsingle this, System.IAsyncResult result)
times2fcn
을 호출합니다.
asyncRes = myDel.BeginInvoke(6,[],[]); while asyncRes.IsCompleted ~= true pause(0.05) % Use pause() to let MATLAB process event end [a1,a2] = myDel.EndInvoke(asyncRes); a1
a1 = 12
입력 인수
asyncResult
— 객체
System.IAsyncResult
BeginInvoke
에서 반환하는 객체로, .NET System.IAsyncResult
객체로 지정됩니다.
res0,...,resN
— 결과
임의의 유효한 유형
대리자에서 반환되는 비동기 호출의 0개에서 N개(있는 경우)까지의 결과로, 임의의 유효한 유형으로 지정됩니다. out
및/또는 ref
파라미터를 포함하는 메서드용입니다. 인수의 개수는 다음을 더한 합입니다.
반환 값 개수(
0
또는1
)out
및ref
인수의 개수
출력 인수
result
— 결과
임의의 유효한 유형
비동기 호출의 결과로, 임의의 유효한 유형으로 반환됩니다.
res0,...,resN
— 결과
임의의 유효한 유형
대리자에서 반환되는 0개에서 N개(있는 경우)까지의 결과로, 임의의 유효한 유형으로 반환됩니다. out
및/또는 ref
파라미터를 포함하는 메서드용입니다.
버전 내역
R2011a에 개발됨
MATLAB 명령
다음 MATLAB 명령에 해당하는 링크를 클릭했습니다.
명령을 실행하려면 MATLAB 명령 창에 입력하십시오. 웹 브라우저는 MATLAB 명령을 지원하지 않습니다.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)