【发布时间】:2015-01-19 10:44:50
【问题描述】:
在我的应用程序中,我有一些操作日志。在那里,我将某些方法的最后几次调用保存在我的应用程序中,如下所示:
saveLastAction(MethodBase.GetCurrentMethod(), getCurrentStatus(), item, /*loadFresh*/ false);
它允许我浏览和刷新我的最后一个操作
public void Refresh(bool loadFresh = true)
{
if (!isInitialized) return;
try
{
lastStatus = getCurrentStatus();
var parameters = lastActionsParameters.Pop();
var method = lastActions.Pop();
//Set the load Fresh parameter to True
parameters[method.GetParameters().First(pi => pi.Name == "loadFresh").Position] = loadFresh;
//Invoke the Method again with the adopted parameters
method.Invoke(this, parameters);
}
catch
{
}
}
在我将调用 saveLastAction 的方法之一更改为异步之前,我工作得很好。从那时起MethodBase.GetCurrentMethod() 只返回 MoveNext 函数,而不是我调用的实际函数。
有没有办法获取被调用函数的实际 MethodBase 对象,无论是保存时还是调用时都无所谓。
最好的问候 大声笑
【问题讨论】:
-
您提供的信息不够。
标签: c# asynchronous reflection methodbase