一共5题都是关于这方面的,要看一点code,我的答案在最后,请花十分钟时间帮我看下做得对不对,最好能说下原因。一题几题都可以,谢过先。第1题
________________________________________________________________
public delegate void ActionStart(object someAction);
public void ActionCallback(IAsyncResult iar) {} public void DoAction(object action) {
// do some long action
} public void DoActionAsync(object action) {
ActionStart myAction = new ActionStart(DoAction);
AsyncCallback myCallback = new AsyncCallback(ActionCallback);
// "call do action"
(CODE HERE)
}
________________________________________________________________What lines of code, at the location (CODE HERE) above, call DoAction asynchronously and then block until it was finished? A myAction.BeginInvoke(action, null, null);
myAction.EndInvoke();
B myAction.BeginInvoke(action, null, null);
myAction.WaitOne();
C IAsyncResult iar = myAction.BeginInvoke(action, null, null);
myAction.EndInvoke(iar);
D myAction.BeginInvoke();
E IAsyncResult iar = myAction.BeginInvoke(action, myCallback, null);
myAction.EndInvoke(iar); 第2题(和第1题的code差不多,变了个花样来问)
________________________________________________________________
public delegate void ActionStart(object someAction);
public void ActionCallback(IAsyncResult iar) {}public void DoAction(object action) {
// do some long action
}public void DoActionAsync(object action) {
ActionStart myAction = new ActionStart(DoAction);
AsyncCallback myCallback = new AsyncCallback(ActionCallback);
IAsyncResult iar = myAction.BeginInvoke(action, null, null);
myAction.EndInvoke(iar);}
________________________________________________________________
In the above sample code, when calling
DoActionAsync(new Object());
which one of the following lines blocks the code until the asynchronous call to DoAction() is completed? A IAsyncResult iar = myAction.BeginInvoke(action, null, null);
B myAction.EndInvoke(iar);
C AsyncCallback myCallback = new AsyncCallback(ActionCallback);
D iar.AsyncWaitHandle.WaitOne();
E ActionStart myAction = new ActionStart(DoAction);
第3题
________________________________________________________________public class ActionClass { public delegate void ActionStart(object someAction); public void ActionCallback(IAsyncResult iar) {
ActionStart callee = (ActionStart)iar.AsyncState;
callee.EndInvoke(iar);
} public void DoAction(object action) { // do some long action } public WaitHandle DoActionAsync(object action) {
ActionStart myAction = new ActionStart(DoAction);
AsyncCallback myCallback = new AsyncCallback(ActionCallback);
(CODE HERE)
return iar.AsyncWaitHandle;
}
}..WaitHandle whTest = new ActionClass().DoActionAsync(1)
whTest.WaitOne()
________________________________________________________________What line of code in place of (CODE HERE) above correctly calls DoAction asynchronously with a callback to ActionCallback and synchronizes the callback at the statement whTest.WaitOne()? A IAsyncResult iar = myAction.BeginInvoke(action, null, null);
B IAsyncResult iar = myAction.BeginInvoke(action, myCallback, null);
C IAsyncResult iar = myAction.BeginInvoke(action, myCallback, myAction);
D IAsyncResult iar = myAction.BeginInvoke(action, null, myAction);
E IAsyncResult iar = myAction.BeginInvoke(action, myCallback); 第4题(最后1个code题了)
________________________________________________________________public class ActionClass { public delegate void ActionStart(object someAction); public void ActionCallback(IAsyncResult iar) {
ActionStart callee = (ActionStart)iar.AsyncState;
callee.EndInvoke(iar);
} public void DoAction(object action) { // do some long action } public WaitHandle DoActionAsync(object action) {
ActionStart myAction = new ActionStart(DoAction);
AsyncCallback myCallback = new AsyncCallback(ActionCallback);
(CODE HERE)
return iar.AsyncWaitHandle;
}
}..WaitHandle whTest = new ActionClass().DoActionAsync(1)
whTest.WaitOne()
________________________________________________________________What line of code in place of (CODE HERE) above correctly calls DoAction asynchronously with a callback to ActionCallback and synchronizes the callback at the statement whTest.WaitOne()? A IAsyncResult iar = myAction.BeginInvoke(action, myCallback, null);
B IAsyncResult iar = myAction.BeginInvoke(action, null, null);
C IAsyncResult iar = myAction.BeginInvoke(action, myCallback);
D IAsyncResult iar = myAction.BeginInvoke(action, myCallback, myAction);
E IAsyncResult iar = myAction.BeginInvoke(action, null, myAction); 第5题
What arguments does the target method for a callback take?
A The same arguments as the BeginInvoke call on the delegate that started the asynchronous call
B An IAsyncResult object
C A Thread object
D The same arguments as the method being asynchronously called
E A WaitHandle object
我选的是1E,2B,3B,4A,5B,你认为呢?谢谢
________________________________________________________________
public delegate void ActionStart(object someAction);
public void ActionCallback(IAsyncResult iar) {} public void DoAction(object action) {
// do some long action
} public void DoActionAsync(object action) {
ActionStart myAction = new ActionStart(DoAction);
AsyncCallback myCallback = new AsyncCallback(ActionCallback);
// "call do action"
(CODE HERE)
}
________________________________________________________________What lines of code, at the location (CODE HERE) above, call DoAction asynchronously and then block until it was finished? A myAction.BeginInvoke(action, null, null);
myAction.EndInvoke();
B myAction.BeginInvoke(action, null, null);
myAction.WaitOne();
C IAsyncResult iar = myAction.BeginInvoke(action, null, null);
myAction.EndInvoke(iar);
D myAction.BeginInvoke();
E IAsyncResult iar = myAction.BeginInvoke(action, myCallback, null);
myAction.EndInvoke(iar); 第2题(和第1题的code差不多,变了个花样来问)
________________________________________________________________
public delegate void ActionStart(object someAction);
public void ActionCallback(IAsyncResult iar) {}public void DoAction(object action) {
// do some long action
}public void DoActionAsync(object action) {
ActionStart myAction = new ActionStart(DoAction);
AsyncCallback myCallback = new AsyncCallback(ActionCallback);
IAsyncResult iar = myAction.BeginInvoke(action, null, null);
myAction.EndInvoke(iar);}
________________________________________________________________
In the above sample code, when calling
DoActionAsync(new Object());
which one of the following lines blocks the code until the asynchronous call to DoAction() is completed? A IAsyncResult iar = myAction.BeginInvoke(action, null, null);
B myAction.EndInvoke(iar);
C AsyncCallback myCallback = new AsyncCallback(ActionCallback);
D iar.AsyncWaitHandle.WaitOne();
E ActionStart myAction = new ActionStart(DoAction);
第3题
________________________________________________________________public class ActionClass { public delegate void ActionStart(object someAction); public void ActionCallback(IAsyncResult iar) {
ActionStart callee = (ActionStart)iar.AsyncState;
callee.EndInvoke(iar);
} public void DoAction(object action) { // do some long action } public WaitHandle DoActionAsync(object action) {
ActionStart myAction = new ActionStart(DoAction);
AsyncCallback myCallback = new AsyncCallback(ActionCallback);
(CODE HERE)
return iar.AsyncWaitHandle;
}
}..WaitHandle whTest = new ActionClass().DoActionAsync(1)
whTest.WaitOne()
________________________________________________________________What line of code in place of (CODE HERE) above correctly calls DoAction asynchronously with a callback to ActionCallback and synchronizes the callback at the statement whTest.WaitOne()? A IAsyncResult iar = myAction.BeginInvoke(action, null, null);
B IAsyncResult iar = myAction.BeginInvoke(action, myCallback, null);
C IAsyncResult iar = myAction.BeginInvoke(action, myCallback, myAction);
D IAsyncResult iar = myAction.BeginInvoke(action, null, myAction);
E IAsyncResult iar = myAction.BeginInvoke(action, myCallback); 第4题(最后1个code题了)
________________________________________________________________public class ActionClass { public delegate void ActionStart(object someAction); public void ActionCallback(IAsyncResult iar) {
ActionStart callee = (ActionStart)iar.AsyncState;
callee.EndInvoke(iar);
} public void DoAction(object action) { // do some long action } public WaitHandle DoActionAsync(object action) {
ActionStart myAction = new ActionStart(DoAction);
AsyncCallback myCallback = new AsyncCallback(ActionCallback);
(CODE HERE)
return iar.AsyncWaitHandle;
}
}..WaitHandle whTest = new ActionClass().DoActionAsync(1)
whTest.WaitOne()
________________________________________________________________What line of code in place of (CODE HERE) above correctly calls DoAction asynchronously with a callback to ActionCallback and synchronizes the callback at the statement whTest.WaitOne()? A IAsyncResult iar = myAction.BeginInvoke(action, myCallback, null);
B IAsyncResult iar = myAction.BeginInvoke(action, null, null);
C IAsyncResult iar = myAction.BeginInvoke(action, myCallback);
D IAsyncResult iar = myAction.BeginInvoke(action, myCallback, myAction);
E IAsyncResult iar = myAction.BeginInvoke(action, null, myAction); 第5题
What arguments does the target method for a callback take?
A The same arguments as the BeginInvoke call on the delegate that started the asynchronous call
B An IAsyncResult object
C A Thread object
D The same arguments as the method being asynchronously called
E A WaitHandle object
我选的是1E,2B,3B,4A,5B,你认为呢?谢谢
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货