I know this has been answered before but I am stuck. I have this class,
public class Job : IJob
{
public void Execute(IJobExecutionContext context)
{
}
}
and I want to call this method which is inside another class:
namespace MySync
{
public partial class Sync1 : Form
{
public void startSync()
{
// ...
How do I access the startSync()
? Making it static
doesn't help cause there are textbox and such inside.
My answer is based on author's comments under the question.
Now it finally became clear what author tries to achieve and what he is doing wrong :) Author is using Quartz.NET to schedule sending of a ZIP package on regular basis. After package was sent author wants to update a textbox inside user's WinForms app with status like "Congrats! ZIP was sent" What he obviously fails to understand is how delayed jobs (in particular, Quartz.NET) and .NET memory model works.
So, author has two possibilities:
In first case we have just one windows process and AppDomain (obviously, app will need to run 24x7 in order to be able to sent ZIPs on regular basis; delayed jobs are not executed when app is closed), so communication between two object instances is not a problem. Now lets assume that author solved job serialization issue (job is saved, for example, in MongoDB before execution) and Quartz.NET engine could acquire instance of Sync1 form object. What does he get in result? Exactly! He gets very expensive Task.Run(() => { });
. It would be a lot easier to write simple in-process scheduler by yourself :)
In second case Quartz.NET runs as standalone service (so, two windows processes on one or two different machines). Because .NET is so good/bad it will not allow us to simply reference an object from another process, that is why delayed job will NEVER be able to update text box in author's Sync1 form. Solutions that were offered here will create new instance of Sync1 type that has nothing to do with instance in his WinForms app.
Summary for lazy developers: @G90 will not be able to implement what he wants because it is either against Quartz.NET design or against .NET Framework. In order to get it working as he wants, he will have to setup Quartz.NET like is described is second case. Then WinForms application will have to query job status every few minutes and update Sync1 form by itself. It is quite easy to implement, Google and SO will help you to find examples.