How can i raised custom event permanently?

using System;
using System.IO;
public class FileSizeWarningEventArgs : EventArgs
private readonly string _filePath;
private readonly decimal _fileSize;
public FileSizeWarningEventArgs(FileInfo file)
_filePath = file.FullName;
_fileSize = file.Length;
public string FilePath
get { return _filePath; }
public decimal FileSize
get { return _fileSize; }
public delegate void FileSizeWarningEventHandler(object sender, FileSizeWarningEventArgs e);
public class FileSizeMonitor
private event FileSizeWarningEventHandler _fileSizeWarning;
private readonly decimal _thresholdSizeInByte;
private readonly FileInfo _file;
public FileSizeWarningEventHandler FileSizeWarning
get { return _fileSizeWarning; }
set { _fileSizeWarning = value; }
public FileSizeMonitor(string filePathToMonitor)
_thresholdSizeInByte = 500;
try
_file = new FileInfo(filePathToMonitor);
catch (Exception ex)
Console.WriteLine("Exception occurred! Message: {0}", ex.Message);
public void CheckFileSize()
if (_file != null && _file.Length > _thresholdSizeInByte)
OnFileSizeWarning(new FileSizeWarningEventArgs(_file));
protected void OnFileSizeWarning(FileSizeWarningEventArgs e)
if (_fileSizeWarning != null)
_fileSizeWarning(this, e);
class Program
static void Main()
var file1 = new FileSizeMonitor("C:\\1.txt");
file1.FileSizeWarning += file1__fileSizeWarning;
file1.CheckFileSize();
public static void file1__fileSizeWarning(object sender, FileSizeWarningEventArgs e)
Console.WriteLine("The File Size is larger than threshold, Current File Size: {0}Byte", e.FileSize);
how can i change above code to raise event whenever file size has been larger than threshold?
what is advantage of Event when I can use following code instead? 
using System;
using System.IO;
public class FileSizeMonitor
private readonly decimal _thresholdSizeInByte;
private readonly FileInfo _file;
public FileSizeMonitor(string filePathToMonitor)
_thresholdSizeInByte = 500;
try
_file = new FileInfo(filePathToMonitor);
catch (Exception ex)
Console.WriteLine("Exception occurred! Message: {0}", ex.Message);
public void CheckFileSize()
if (_file != null && _file.Length > _thresholdSizeInByte)
Console.WriteLine("The File Size is larger than threshold, Current File Size: {0}Byte", e.FileSize);
class Program
static void Main()
var file1 = new FileSizeMonitor("C:\\1.txt");
file1.CheckFileSize();
thank you/.

Hi, if your files keeps growing in size...you can add a  thread, may be with background priority, in your first code which will check size of file at some interval and if at any instance it found it larger than the limit it will raise the event
which can be used to show error message.
Here is a your modified code...
using System;
using System.IO;
using System.Threading;
namespace SimpleUI
    publicclassFileSizeWarningEventArgs : EventArgs
        privatereadonlystring _filePath;
        privatereadonlydecimal _fileSize;
        public FileSizeWarningEventArgs(FileInfo file)
            _filePath = file.FullName;
            _fileSize = file.Length;
        publicstring FilePath
            get { return _filePath; }
        publicdecimal FileSize
            get { return _fileSize; }
    publicdelegatevoidFileSizeWarningEventHandler(object sender, FileSizeWarningEventArgs e);
    publicclassFileSizeMonitor
        publiceventFileSizeWarningEventHandler FileSizeWarning;
        privatereadonlydecimal _thresholdSizeInByte;
        privatereadonlyThread _demonThread;
        privatereadonlystring _filePathToMonitor;
        public FileSizeMonitor(string filePathToMonitor, decimal threshold)
            _filePathToMonitor
                = filePathToMonitor;
            _thresholdSizeInByte
                = threshold;
            _demonThread
                = newThread(CheckFileSizeDemon);
        publicvoid Start()
            if (!_demonThread.IsAlive)
                _demonThread.Start();
        publicvoid CheckFileSizeDemon()
            try
while (true)
                    var _file = new FileInfo(_filePathToMonitor);
                    if (_file != null && _file.Length > _thresholdSizeInByte)
                        OnFileSizeWarning(new FileSizeWarningEventArgs(_file));
                    Thread.Sleep(10000);
            catch (Exception ex)
                Console.WriteLine("Exception occurred! Message: {0}", ex.Message);
        protectedvoid OnFileSizeWarning(FileSizeWarningEventArgs e)
            if (FileSizeWarning != null)
                FileSizeWarning(this, e);
    internalclassProgram
        privatestaticvoid Main1()
            var file1
                = newFileSizeMonitor("C:\\1.txt", 500);
            file1.FileSizeWarning
                += file1__fileSizeWarning;
            file1.Start();
        publicstaticvoid file1__fileSizeWarning(object sender, FileSizeWarningEventArgs e)
            Console.WriteLine("The File Size is larger than threshold, Current File Size: {0}Byte", e.FileSize);

Similar Messages

  • How can I make custom event alerts?

    This is what I'm offered when I try to sent an event alert:
    http://img543.imageshack.us/img543/5805/img0017w.png
    But what if for example I would like to set the alert 3 hours and 20 minutes before?
    Thank you in advance

    killwin98 wrote:
    I'm using Google Calendar as my 3rd party program, but the whole point is to set these events on the iPhone. Is there an iPhone app that can create these custom event alerts?
    I have not yet found an app that creates custom times for Calendar's, only on Tasks.

  • How can I use custom repeating event in my iPad Air calendar iOS 8.0.2

    How can I use custom repeating event in my iPad Air calendar iOS 8.0.2?

    Unless something has changed, you can't. The iPad has limited ability to make repeats. However if you make the custom repeats in another program you can send them to or import them into your calendar and the iPad will respect the custom repeat.

  • FPM Raise Custom Event - Navigation to a FPM Screen from one custom FPM Scr

    Hi
      I added an introductory screen ( start up screen ) to the FPM Framework for a bank ESS application.
    Its showing up fine with in the RoadMap. ( used IVAC window... )
    How can i navigate to the following FPM Screen from my custom introductory FPM Screen.
    I had also defined an event link in the service config FPM Application.
    But i don't know how to raise that custom event or how to make a custom event.
    RAISE_EVENT. ... only shows standard events i guess.
    ( i have the SDN DAY Document ) but, Its an urgency , at the moment....

    The question is How can i add a custom event and call it, in order to go to the next screen ( Overview Screen ) from my custom FPM Introduction screen ?
    Any one ?

  • How can we use Custom MessageBox in SelectionChangedEvent of LongListSelector for Windows Phone 8

    Dear Sir/Madam,
    How can we use Custom MessageBox in SelectionChangedEvent of LongListSelector for Windows Phone 8.
    Actually my problem is that When i am using Custom  MessageBox in SelectionChangedEvent of LongListSelector,when i am click Open(Left Button) it's working fine and navigated correctly,But when i am Click the No(Right Button) then it stayed in same page
    but all that page is in stuckup i mean that page is not working and not doing any event.
    My C#.net Code
    private async void userPageLongListSelector_SelectionChanged(object sender, SelectionChangedEventArgs e)
    if (e.AddedItems.Count > 0)
    if (userPageLongListSelector.SelectedItem == null)
    return;
    if (dbTenMin == null)
    dbTenMin = new Database(ApplicationData.Current.LocalFolder, "tenMInDBSchema.db");
    await dbTenMin.OpenAsync();
    var res = (sender as LongListSelector).SelectedItem as _10Min._10MinClass.minUserPages;
    var resIndex = (sender as LongListSelector).ItemsSource.IndexOf(userPageLongListSelector.SelectedItem);
    string selectedPageName = res.userPages.ToString();
    string selectedPageDesignUser = res.pageDesignUser.ToString();
    int selectedIndex = resIndex;
    CustomMessageBox messageBox = new CustomMessageBox()
    Caption = "Message...!",
    Message = "This form need offline datalist,Please load now.",
    LeftButtonContent = "Open",
    RightButtonContent = "No"
    messageBox.Dismissed += (s1, e1) =>
    switch (e1.Result)
    case CustomMessageBoxResult.LeftButton:
    string uidAndpwd = _10MinClass._10MinStaticClass.csUidAndPwd.ToString();
    _10MinClass._10MinStaticClass.csDataListPageDetails = selectedPageDataDetailsForSchema.ToString();
    _10MinClass._10MinStaticClass.csAllDataLists = offlineDataBaseDataListNam;
    _10MinClass._10MinStaticClass.csNotCreatedSchemaNameOfDBList = notCreatedDataLists;
    userPageLongListSelector.SelectedItem = null;
    if (dbTenMin != null)
    dbTenMin.Dispose();
    dbTenMin = null;
    NavigationService.Navigate(new Uri("/10MinformDataList.xaml", UriKind.Relative));
    else
    NavigationService.Navigate(new Uri("/10MinformDataList.xaml", UriKind.Relative));
    break;
    case CustomMessageBoxResult.RightButton:
    break;
    case CustomMessageBoxResult.None:
    break;
    default:
    break;
    messageBox.Show();
    Same custom messagebox code working in Phone_BackKeyPress event i am writing the code in Right Button that e.OriginalSource.ToString(); then it is working fine.
    But It is not working in Selection Changed Event in LongListSelector control in Windows Phone 8.
    Please help me,as soon as possible.
    Thanks & Regards,
    SrinivaaS.

    What happens if you leave the implementation for LeftButton empty as well , does the page gets stuck in that case also, if you press left button?
    i.e.
    CustomMessageBox messageBox = new CustomMessageBox()
    Caption = "Message...!",
    Message = "This form need offline datalist,Please load now.",
    LeftButtonContent = "Open",
    RightButtonContent = "No"
    messageBox.Dismissed += (s1, e1) =>
    switch (e1.Result)
    case CustomMessageBoxResult.LeftButton:
    break;
    case CustomMessageBoxResult.RightButton:
    break;
    case CustomMessageBoxResult.None:
    break;
    default:
    break;
    messageBox.Show();
    http://developer.nokia.com/community/wiki/Using_Crypto%2B%2B_library_with_Windows_Phone_8

  • How can I insert an event in my clendar and set it to repeat every 3 months?

    Anybody knows how can I create an event on my iphone 5 calendar and set it torepeat every 3 months?

    If you happen to have Apple computer(s), and you are synching your iPhone calendar to your computer's calendar, you can set up an "every 3 month" period on your computer.  Simply use the calendar app on your Apple computer, access the event, access "Repeat", choose "custom", then "Monthly", then set up the interval you want.  It will sync with and properly be represented on your iPhone.

  • How do we raise an event into R/3 from a BW info-package ?

    Hi friends,
    Is there a way to raise an event from a BW stand-along info-package into the R/3 system, without using Event Collector..?
    I cannot use the subsequent event option in the package itself since that will raise the event only into BW. I want it into R/3. I can probably raise an event from the package to start a process-chain and then add a step in the PC to run a pgm to raise an event into R/3.
    But I am trying to see if there is a better and simpler way without having to create a extra PC.
    I am on the BW 3.1 system.
    Any suggestions/solutions will be greatly appreciated.
    Thanks
    lz70d71

    hi, here is what you do: This addition is with respect to the previous reply
    You need an event from BW to R/3
    Step1: create a custom FM copy of BP_EVENT_RAISE  and making it rfc enable. To make a FM RFC enabled you just need to tick the radio button in the attributes of the FM.
    Step2: Create a custome z program in BW and call FM z_bp_event_raise created in ECC.
    Step3: call that program in Process chain.
    hope this helps. if you need more let me know.
    thanks
    syed

  • How can I add an event to my calendar that occurs every third day...I have an ipad.

    How can I add an event to my calendar that occurs every third day?

    Do you happen to have a Mac?  If so, and if you use iCloud to sync your calendars, you can do that on your Mac and your iPad will understand.  But you cannot create such a repitition (or something like the third Tuesday of each month) on your iPad.
    In Calendar on your Mac, you would create the event, choose "Custom ..." as the repitition frequency, then choose "Days" and choose every 3 days.

  • How can I set an event to repeat on a week day rather than a numerical day of each month?

    How can I set an event to repeat on a week day rather than a numerical day of each month? I see an option at the bottom of the repeat window .... but I cannot use it. Actually, when I try it freezes up my Calendar.
    Lorrene Baum Davis

    These scrrenshots are from Snow Leopard - I would think that Lion wouldn't be too much different.

  • How can i clear all events in ical

    how can i clear all events in ical

    Try typing "." without the exclamation points in the iCal search window. Then simply highlight all the entries > Edit/Delete

  • How can we define custom error page in protal application

    How can we define custom error page in protal application, like we define "jsp Error page " in JSPs

    Hi,
    Check these:
    Customization of Portal Runtime Errors and portal standard error codes
    http://help.sap.com/saphelp_nw04/helpdata/en/9a/e74d426332bd30e10000000a155106/frameset.htm
    http://help.sap.com/saphelp_nw04/helpdata/en/ec/1273b2c413b2449e554eb7b910bce7/frameset.htm
    Regards,
    Praveen Gudapati

  • How can I move an event in my calendar to my "completed" calendar without changing all the events in the series?

    How can I move an event in my calendar to my "completed" calendar without changing all the events in the series?
    As Apple has yet to upgrade iCalendar so I can check off my events as I complete them (no, I do not want to use a task list/reminder list), I want to be able to move my events to my "completed" events calendar as I complete them. The issue is that most of my events are repeating events, and it changes the entire series. How do I change only the event I clicked on using my iPhone?
    Thanks

    If you change anything in a repeating calendar entry it will give you the option of disconnecting it from the series. So may any random change, choose to not change the series.

  • HOW CAN I DELETE AN EVENT WITHOUT  HAVING TO SELECTING IT FROM THE LIBRARY?

    I have a big problem.
    I want to delete an entire event from my library because everytime I select it imovie freezes and then close itself up. So I have to re-open imovie again. And when I want to select that particular event again the same problem occures. So I can not select that particular event. Therefore I can take NO action on this event.
    HOW CAN I DELETE AN EVENT WITHOUT HAVING TO SELECTING IT FROM THE LIBRARY?
    (Everytime I select it imovie closes itself up)
    All other events work fine. I believe The footage had a problem from capturing. but now it's in my computer and i can't open it.
    Please help me, I don't need this event, I can't open it therefore I can't use it and it takes place on my hardrive for nothing.
    Thank you

    One can delete it from one's computer. In the finder go to homeuser, movies, imovie events, delete the footage.
    Then reopen iMovie and see if that helps.
    Hugh

  • TS3714 how can i set an event in the calander to repeat on 2nd thurday of every month

    how can i get an event to show in calander every 2nd thursday every momth

    Try the app "Week Cal".

  • How can i add custom attributes to a new Class Object using the API ?

    Hello everyone,
    Here is my problem. I just created a subclass of Document using the API (not XML), by creating a ClassObjectDefinition and a ClassObject. Here is the code :
    // doc is an instance of Document
    ClassObject co = doc.getClassObject();
    ClassObjectDefinition cod = new ClassObjectDefinition(ifsSession);
    cod.setSuperclass(co);
    cod.setSuperclassName(co.getName());
    cod.setName("MYDocument");
    ClassObject c = (ClassObject)ifsSession.createSchemaObject(cod);
    Everything seems to be OK since i can see the new class when i use ifsmgr. But my question is : how can i add custom attributes to this new class ? Here is what i tried :
    AttributeDefinition value = new AttributeDefinition(ifsSession);
    value.setAttribute("FOO", AttributeValue.newAttributeValue("bar"));
    c.addAttribute(value);
    But i got the following error message :
    oracle.ifs.common.IfsException: IFS-30002: Unable to create new LibraryObject
    java.sql.SQLException: ORA-01400: impossible d'insirer NULL dans ("IFSSYS"."ODM_ATTRIBUTE"."DATATYPE")
    oracle.ifs.server.S_LibraryObjectData oracle.ifs.beans.LibrarySession.DMNewSchemaObject(oracle.ifs.server.S_LibraryObjectDefinition)
    oracle.ifs.beans.SchemaObject oracle.ifs.beans.LibrarySession.NewSchemaObject(oracle.ifs.beans.SchemaObjectDefinition)
    oracle.ifs.beans.SchemaObject oracle.ifs.beans.LibrarySession.createSchemaObject(oracle.ifs.beans.SchemaObjectDefinition)
    void fr.sword.ifs.GestionDocument.IFSDocument.createDocument(java.lang.String)
    void fr.sword.ifs.GestionDocument.IFSDocument.main(java.lang.String[])
    So, what am i doing wrong ?
    More generally, are we restricted in the types of the attributes ? (for example, would it be possible to add an attribute that would be an inputStream ? Or an object that i have already created ?).
    Any help would be appreciated. Thanks in advance.
    Guillaume
    PS : i'm using Oracle iFS 1.1.9 on NT4 SP6 and Oracle 8.1.7
    null

    Hi Guillaume,
    you're welcome. Don't know exactly, but assume that ATTRIBUTEDATATYPE_UNKNOWN
    is used to check for erronous cases only
    and it shouldn't be used otherwise.
    Creating your own objects could be simply done via
    ClassObject ifsClassObject;
    DocumentDefinition ifsDocDef = new DocumentDefinition(ifsSession);
    // get class object for my very own document
    ifsClassObject = ClassObject.getClassObjectFromLabel(ifsSession, "MYDOCUMENT");
    // set the class for the document i'd like to create
    ifsDocDef.setClassObject(ifsClassObject);
    // set attributes and content for the document...
    ifsDocDef.setAttribute("MYFOO_ATTRIBUTE",....);
    ifsDocDef.setContent("This is the content of my document");
    // create the document...
    PublicObject doc = ifsSession.createPublicObject(ifsDocDef);
    null

Maybe you are looking for