473,699 Members | 2,722 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Need functionality similar to TransactionScop e and TransactionInfo rmation.LocalId entifier

ste
Please bear with this post.. its abit long winded.. but i thought it was
important to describe what i am trying to achieve before i ask the questions
(at the bottom)

Thanks.....in advance

Steve

Okay.. here goes........... .......

I have a class library, which i have been tasked with tracing. One of my
requirements is to associate a unique identifier with the tracing.

For example..

MyClassLibrary. InvokeMethod( "3F2504E0-4F89-11D3-9A0C-0305E82C3301" );

would produce a trace output similiar to the following...... ......

trace.source : 1 3F2504E0-4F89-11D3-9A0C-0305E82C3301 ---> loading
config settings
trace.source : 1 3F2504E0-4F89-11D3-9A0C-0305E82C3301 --->
initialising queue emq\qm1
trace.source : 1 3F2504E0-4F89-11D3-9A0C-0305E82C3301 ---> placing msg
"hello" on queue emq\qm1
trace.source : 1 3F2504E0-4F89-11D3-9A0C-0305E82C3301 ---> reading msg
"world" from queue emq\qm1
Obviously the easiest way to implement this behaviour is to just pass the
identifier in to each method in the class library that needs it ..eg

namespace MyClassLibrary
{
class InvokeMethod(st ring identifier)
{
// do smothing
Trace(identifie r, .. other stuff )
}
}

However for a very large class library such as mine, this means passing in
the identifier parameter to almost every method; which quickly gets
unnaceptable and messy. I cannot use a singleton or any form of static
instance of the identifier because the library will be used in a
multithreaded environmet such as a web server.

For example.. my library is used like..

class MyWebService
{
[WebMethod]
void Pointless()
{
MyClassLibrary. InvokeMethod("3 F2504E0-4F89-11D3-9A0C-0305E82C3301");
MyClassLibrary. InvokeMethod2(" 3F2504E0-4F89-11D3-9A0C-0305E82C3301");
}
}
Ideally i want to be able to write

using( MyClassLibrary. SetUniqueID("3F 2504E0-4F89-11D3-9A0C-0305E82C3301") )
{
MyClassLibrary. InvokeMethod1() ;
MyClassLibrary. InvokeMethod2() ;
}

This can be done using the System.Transact ion.Transaction Scope class, using
it i am able to code

using(transacti onScope = new TransactionScop e())
{
MyClassLibrary. InvokeMethod1() ; // buried deep within my
library i can now call Transaction.Tra nsactionInforma tion.LocalIdent ifier
MyClassLibrary. InvokeMethod2() ;
}

I can get the current transaction id, whilst inside the transaction scope by
simply querying the Transaction.Inf ormation.LocalI dentifierproper ty inside
my trace methods. This is perfect for my needs, but it means i have to wrap
all my library code in a transaction scope. I do not know the side effects
/performance implications this may have, so i am ideally looking for a
similar custom solution.

Q) Does anyone know how to implement functionality similar to the
transaction scope / transaction information mechanism? All i want to is to
get a thread safe identifier in a way that i do not have to pass the
identifer through the object tree. Without using a global [multiple
instances and thread safety].

Q) Can anyone think of an alternative mechanism?

}


---
avast! Antivirus: Outbound message clean.
Virus Database (VPS): 0606-4, 10/02/2006
Tested on: 10/02/2006 21:51:47
avast! - copyright (c) 1988-2005 ALWIL Software.
http://www.avast.com

Feb 10 '06 #1
0 1946

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
2055
by: Rick_Kierner | last post by:
I am attempting to use the TransactionScope class to manage my transactions. I am running into an issue. My web server is in an NT work group. My SQL Server is in a domain. When my code attempts to execute the Complete method of the TransactionScope object, I get the following error: "The transaction has already been implicitly or explicitly committed or aborted" I have tried altering the registry entry to...
3
7116
by: OUSoonerTaz | last post by:
We are randomly getting this error message on our development and staging machines: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.; at System.Data.Common.UnsafeNativeMethods.OraMTSJoinTxn(OciEnlistContext pCtxt, IDtcTransaction pTrans) at System.Data.OracleClient.TracedNativeMethods.OraMTSJoinTxn(OciEnlistContext pCtxt, IDtcTransaction pTrans)
6
1769
by: Mukesh | last post by:
Hi, I am new to 2.0 framework. I am trying to use TransactionScope in the following code. I took four lables. Started TransactionScope scope. After setting values to three labels I throw an exception. I expexted all label value would remain as method Complete() of TransactionScope scope was not complete. But actually three labels are showing new values. label1.Text="1";
3
7716
by: kikapu | last post by:
Hi to all folks, i am trying to understand the use of System.Transactions in general and TransactionScope particularly. What am i allowed to do in a using statement that wraps a TransactionScope object, so this to be rollback in case of an exception or when i do not call scope.complete ?? I mean, can i set an object's variables and then un-done these sets
4
5554
by: hardieca | last post by:
Hi, I'd really like to use TransactionScope within the Business Layer of my web application. A book I'm reading makes a note that it should not be used in a shared web hosting environment because the server may get re-configured. Can anyone elaborate on this? Regards, Chris
5
8634
by: RP | last post by:
I tried following code but it generates error at line (using .....): Error 23 The type or namespace name 'TransactionScope' could not be found (are you missing a using directive or an assembly reference?) =========================================== private void cmdProceed_Click(object sender, EventArgs e) {
0
1437
by: RP | last post by:
I have a two classes, first named "ModCon" has procedures written for connections and the second named "ModRes" contains functions and procedures that can be reused. For my question it is important to add sample codes of the two classes and later the code from a Form's button click event which is giving problem. ======================================== public string ConString; public SqlConnection myCN = new SqlConnection();
3
8021
by: Aleksey Timonin | last post by:
Hi guys, I tried to use TransactionScope on to defferent TableAdapters like this: using (TransactionScope transScope = new TransactionScope(TransactionScopeOption.Required)) { TableAdapter1.InsertQuery(id, name); TableAdapter2.InsertQuery(id, customerName, customerAddress); transScope.Complete(); }
3
2890
by: Michael Schöller | last post by:
Hello, First of all english is not my natural language so please fogive me some bad mistakes in gramatic and use of some vocables :). I have a great problem here. Well I will not use it anymore but I want to know why it is as it is ^^. I tried with .NET3.0 but I think it will be the same with 2.0 and 3.5. MSDTC is configured and working.
0
8633
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9199
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8902
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7787
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6552
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4392
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4642
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3076
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2016
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.