Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 930703
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T20:22:50+00:00 2026-05-15T20:22:50+00:00

In my current project I’m using classes which implement the following ITransaction interface shown

  • 0

In my current project I’m using classes which implement the following ITransaction interface shown below. This is a generic interface for a transaction that can be undone. I also have a TransactionSet class which is used to attempt multiple Transactions or TransactionSets, and can ultimately be used to create a tree of transactions.

Some implementations of ITransaction keep temporary references to object instances or files it may use later if there is a call to Undo(). A successful transaction can later be confirmed after which Undo() is no longer allowed and there is thus also no longer a need for the temporary data. Currently I’m using Dispose() as my confirmation method to clean up any temporary resources.

However, now I’d like my transactions to also fire events to notify other classes of what has taken place. I do not want the events to fire unless the transaction is confirmed. Because I don’t want to allow a transaction to fire events multiple times by being undone and then run again.

Since I’m using Dispose() to confirm a transaction is there anything wrong with also firing these events from it? Or would it be better to have a separate Confirm() method on my interface that fires the events in addition to Dispose() which cleans up the temporary data? I can’t think of any case where I would want to confirm, but not dispose a transaction. Yet it’s not entirely clear to me what I should and should not do within Dispose().

public enum TransactionStatus
{
    NotRun, // the Transaction has not been run, or has been undoed back to the original state
    Successful, ///the action has been run and was successful
    Error //there was an attempt to run the action but it failed
}

/// <summary>
/// Generic transaction interface
/// </summary>
public interface ITransaction
{
    TransactionStatus Status { get; }

    /// <summary>
    /// Attempts the transaction returns true if successful, false if failed.
    /// If failed it is expected that everything will be returned to the original state.
    /// Does nothing if status is already Successful
    /// </summary>
    /// <returns></returns>
    bool Go();

    /// <summary>
    /// Reverts the transaction
    /// Only does something if status is successful.
    /// Should return status to NotRun
    /// </summary>
    void Undo();

    /// <summary>
    /// A message describing the cause of the error if Status == Error
    /// Otherwise equal String.Empty
    /// </summary>
    string ErrorMessage { get; }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T20:22:51+00:00Added an answer on May 15, 2026 at 8:22 pm

    IDisposable is simply a runtime-integrated design pattern that facilitates object cleanup in a more efficient manner than finalization. There is very little you “can’t” do in a disposal method, however you should be wary of doing some things.

    While the IDisposable.Dispose() method is not a “real” destructor or finalizer, it can adversely affect the lifetime of an object if other objects maintain (or perhaps even take) a reference to the disposing object during disposal events. If you are careful about how you implement such a system, you can mitigate the possible side effects. However, it is important to realize the potential that such an implementation offers…such as increased attack surface for a malicious coder to exploit by, say, keeping your transaction objects alive indefinitely.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 495k
  • Answers 495k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer It's hard to tell exactly what state your installation is… May 16, 2026 at 11:14 am
  • Editorial Team
    Editorial Team added an answer If you can't add constraints that propagates the delete, you… May 16, 2026 at 11:14 am
  • Editorial Team
    Editorial Team added an answer Web servers can choose what response to send after processing… May 16, 2026 at 11:14 am

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

Our current project does not use Hibernate (for various reasons) and we are using
Current project recently had a mess of changes to the DB schema. These were
Current Project Setup I've been working on a web-based chat, similar to Facebook chat.
My current project is in Rails. Coming from a Symfony (PHP) and Django (Python)
My current project uses NUnit for unit tests and to drive UATs written with
My current project involves deploying an upgraded .exe file that runs as a Windows
My current project involves writing Perl code inside a Solaris VMWare appliance (hosted on
My current project has 5 separate automated builds that kick off after each check-in:
My current project creates UI by WPF at runtime. Everything works well. The only
The current project I inherited mainly revolves around one unnormalized table. There are some

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.