public void run()
    {
        /**
         * This class periodically publishes change events to the zone. This
         * method starts up the thread that publishes the change events.
         *
         * A normal SIF Agent would, instead look for changes in the application's database
         * and publish those as changes.
         */

        Console.WriteLine
            ("Event publishing enabled with an interval of " + EVENT_INTERVAL / 1000 +
            " seconds.");

        Random random = new Random();

        bool isProcessing = true;

        // Go into a loop and send events
        while (isProcessing)
        {
            try
            {
                Thread.Sleep(EVENT_INTERVAL);

                SifDataObject changedObject = fData[random.Next(fData.Count)];
                SifDataObject eventObject   = Adk.Dtd.CreateSIFDataObject(getElementDef());
                eventObject.SetElementOrAttribute
                    ("@PersonRefId",
                    changedObject.GetElementOrAttribute("@PersonRefId").
                    TextValue);

                // Create a change event with a random Learner ID;
                string newNum = "A" + random.Next(999999);
                eventObject.SetElementOrAttribute("LocalId", newNum);

                fZone.ReportEvent(eventObject, EventAction.Change);
            }
            catch (Exception ex)
            {
                Console.WriteLine("Error during event processing: " + ex);
                isProcessing = false;
            }
        }
    }
    private SifDataObject createPerson(string id,
                                       string lastName,
                                       string firstName,
                                       string number,
                                       string street,
                                       string locality,
                                       string town,
                                       string post,
                                       string phone,
                                       string gender,
                                       string grade,
                                       EthnicityCodes ethnicity,
                                       string birthDateyyyyMMdd)

    {
        SifDataObject person = createPersonObject(id);

        person.SetElementOrAttribute("@RefId", Adk.MakeGuid());

        Name name = new Name(NameType.CURRENT_LEGAL, firstName, lastName);
        PersonalInformation personal = new PersonalInformation(name);

        person.AddChild(CommonDTD.PERSONALINFORMATION, personal);

        AddressableObjectName aon = new AddressableObjectName();

        aon.StartNumber = number;
        Address address = new Address(AddressType.CURRENT, aon);

        address.Street   = street;
        address.Locality = locality;
        address.Town     = town;
        address.PostCode = post;
        address.SetCountry(CountryCode.GBR);
        personal.Address = address;

        personal.PhoneNumber = new PhoneNumber(PhoneType.HOME, phone);

        Demographics dem = new Demographics();

        dem.SetEthnicityList(new Ethnicity(ethnicity));
        dem.SetGender(Gender.Wrap(gender));
        try
        {
            dem.BirthDate = SifDate.ParseSifDateString(birthDateyyyyMMdd, SifVersion.SIF15r1);
        }
        catch (Exception pex)
        {
            Console.WriteLine(pex);
        }

        personal.Demographics = dem;

        return(person);
    }