kamagra how much to take

EventArgs Example

In one my past posts, I talked about that CryptoCollaboration using the EventArgs base class because it keeps things nice and generalized, allowing for expanasion for the handling of future event integration. A person emailed me and asked for a practical example of when would use such a thing in a SharePoint WebPart. Eh, ok.

I am going to use an example of a progress class, that, well, as you can guess will display the progress of some sort of execution that happens with a SharePoint WebPart.

The first class is the Process Arguments class (ProcessArgs), that inherits from the EventArgs base class.

  1. public class ProgressArgs : EventArgs
  2. {
  3. private int m_nPercentageComplete = 0;
  4. private DataRow m_oDataRow;
  5.  
  6. public ProgressArgs(DataRow dataRow, int percentageComplete)
  7. {
  8. this.m_oDataRow = dataRow;
  9. this.m_nPercentageComplete = percentageComplete;
  10. }
  11.  
  12. public DataRow CurrentDataRow
  13. {
  14. get
  15. {
  16. return this.m_oDataRow;
  17. }
  18. }
  19.  
  20. public int PercentageComplete
  21. {
  22. get
  23. {
  24. return this.m_nPercentageComplete;
  25. }
  26. }
  27. }

In the next class, there will be the establishment of the event handler that will be called from a sister class by use of a delegate.

  1. public delegate void ProgressEventHandler(object sender, ProgressArgs e);

Now that the delegate is established, you can call it in some general class file.

  1. public event ProgressEventHandler ProgressEvent;
  2.  
  3. protected virtual void OnProgress(ProgressArgs e)
  4. {
  5. if (this.ProgressEvent != null)
  6. {
  7. this.ProgressEvent(this, e);
  8. }
  9. }

Then calculate out the progress.

  1. ProgressArgs e = new ProgressArgs(row, (int) ((((double) num) / ((double) this.DBDataTable.Rows.Count)) * 100));
  2. this.OnProgress(e);

I am not saying that this is the only way to do it, but with applications that you plan on extending later it is the route that I have choosen to go in the past. I may at some point explore the deficiencies in a such an approach, however at this current time I just want to finish the damn thing.

Share

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>