Sharepoint 2010 如何从Sharepoint计时器作业中浮动异常?
我有一个类MyMainApplication,它是一个SPIisWebServiceApplication。因此,它是在IIS下托管和运行的 我有一个自定义sharepoint计时器作业,比如说命名为CustomTimerJob类,它是从SPJobDefinition类派生的。因此,计时器作业在OWSTimer.exe下运行 我有两个问题:[请参阅下面的代码,以关联这些问题]Sharepoint 2010 如何从Sharepoint计时器作业中浮动异常?,sharepoint-2010,Sharepoint 2010,我有一个类MyMainApplication,它是一个SPIisWebServiceApplication。因此,它是在IIS下托管和运行的 我有一个自定义sharepoint计时器作业,比如说命名为CustomTimerJob类,它是从SPJobDefinition类派生的。因此,计时器作业在OWSTimer.exe下运行 我有两个问题:[请参阅下面的代码,以关联这些问题] CutomTimerJob中的变量是否可以从调用方访问,在我的示例中是var job=new CustomTimerJo
> Class MyMainApplication : SPIiWebServiceApplication
> {
> // something
> .
> .
> .
> void some_function()
> {
> // Create and run the timer job immediately
>
> var job = new CustomTimerJob()
> job.RunNow();
>
> // Give it a bit of time before checking the status
> Thread.Sleep(5000);
>
> // Want to print the status to see if it was changed when it ran
> Console.Writeln( job.Status );
>
> }
>
> }
>
> ----------------------
>
> class CustomTimerJob : SPJobDefinition
> {
>
> public Boolean status;
> // something
>
> public override void Execute(Guid contentDbId)
> {
> status = true;
> try {
> // do some processing
> } catch (Exception) {
>
> // Can I throw the exception up from here ? And will the calle get the exception
> // throw new CustomException(e);
>
> }
>
> }
我真的很感激那些有心一直读到这一行的读者。我的荣誉
提前感谢。方法
SPJobDefinition.RunNow()
只安排执行,然后在OWSTimer.exe
进程的上下文中执行。因此,你的问题的答案如下:
RunNow()
的位置。通常,允许未经处理的异常在自定义计时器作业之外传播是一种不好的做法,因为该作业会被视为失败。除非这是正确处理异常所需要的确定CustomTimerJob何时完成执行的最佳方法是什么?(这是runonce计时器作业,由RunNow触发)