Advertisement
Guest User

Untitled

a guest
Jun 16th, 2019
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.75 KB | None | 0 0
  1. // define the job and tie it to our DumbJob class
  2.  
  3. IJobDetail job = JobBuilder.Create<DumbJob>()
  4. .WithIdentity("myJob", "group1")
  5. .UsingJobData("jobSays", "Hello World!") // key value (put required key and value from HttpContext)
  6. .UsingJobData("myFloatValue", 3.141f)
  7. .Build();
  8.  
  9. public class DumbJob : IJob
  10. {
  11. public async Task Execute(IJobExecutionContext context)
  12. {
  13. JobKey key = context.JobDetail.Key;
  14.  
  15. JobDataMap dataMap = context.JobDetail.JobDataMap;
  16.  
  17. string jobSays = dataMap.GetString("jobSays");
  18. float myFloatValue = dataMap.GetFloat("myFloatValue");
  19.  
  20. await Console.Error.WriteLineAsync("Instance " + key + " of DumbJob says: " + jobSays + ", and val is: " + myFloatValue);
  21. }
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement