Click here to Skip to main content
15,890,512 members
Home / Discussions / .NET (Core and Framework)
   

.NET (Core and Framework)

 
GeneralRe: COM type communication between .NET apps? Pin
lmoelleb25-Sep-07 3:47
lmoelleb25-Sep-07 3:47 
QuestionEditing in Datagrid view Pin
prabhathgk21-Sep-07 5:54
prabhathgk21-Sep-07 5:54 
GeneralRe: Editing in Datagrid view Pin
Paul Conrad31-Dec-07 9:25
professionalPaul Conrad31-Dec-07 9:25 
QuestionIsynchronizeinvoke question Pin
Fayu21-Sep-07 5:39
Fayu21-Sep-07 5:39 
AnswerRe: Isynchronizeinvoke question Pin
TJoe27-Sep-07 3:28
TJoe27-Sep-07 3:28 
GeneralRe: Isynchronizeinvoke question Pin
Fayu28-Sep-07 10:20
Fayu28-Sep-07 10:20 
GeneralRe: Isynchronizeinvoke question Pin
TJoe28-Sep-07 10:52
TJoe28-Sep-07 10:52 
GeneralRe: Isynchronizeinvoke question Pin
Fayu28-Sep-07 11:42
Fayu28-Sep-07 11:42 
Creating a class that follows a "plug and play" model where it can be refrenced by any application(asp.net or winforms) that allows the programmer to use this class without worrying about thread safety(using lock) or syncronization (cross-threading). This class will can be used in a multi threaded environment or a single thread environment. This class will have events that notifies the programmer of 'transaction' statuses. This class will not be dependent on a specific UI component (win control or web control).

Plan:
Create a class that lock object while being used. Also, when the event is triggered, this class will check to see if thread sync is required. If it is, thread will be synced else thread will not be synced.

I hope I have provided enough information for you to be able to judge ifthis is a good solution. Thanks for your prompt replys!!!! The class code is below.


Class Code:
public class BaseObjectClass
{
//Private Fields
private object syncObject;

//Events
public event TransactionStartedEventHandler TransactionStarted;
public event TransactionEndedEventHandler TransactionEnded;


//Consturctors
public BaseObjectClass()
{
syncObject = new object();
}

//Event Methods
public void OnTransactionStarted(object sender, TransactionStartedEventArgs e)
{
//ISynchronizeInvoke sync = this. as ISynchronizeInvoke;

ISynchronizeInvoke sync = null;
if (TransactionStarted != null)
sync = TransactionStarted.Target as ISynchronizeInvoke;

if (sync != null)
{
if (sync.InvokeRequired)
{
TransactionStartedEventHandler tmp = new TransactionStartedEventHandler(OnTransactionStarted);
object[] args ={ sender, e };
sync.Invoke(tmp, args);
return;
}
}

if (TransactionStarted != null)
TransactionStarted(sender, e);
}
public void OnTransactionEnded(object sender, TransactionEndedEventArgs e)
{
ISynchronizeInvoke sync = null;
if (TransactionEnded != null)
sync = TransactionEnded.Target as ISynchronizeInvoke;

if (sync != null)
{
if (sync.InvokeRequired)
{
TransactionEndedEventHandler tmp = new TransactionEndedEventHandler(OnTransactionEnded);
object[] args ={ sender, e };
sync.Invoke(tmp, args);
return;
}
}

if (TransactionEnded != null)
TransactionEnded(sender, e);
}

public virtual object Insert()
{
lock(syncObject)
{
OnTransactionStarted(this, new TransactionStartedEventArgs(ItemCommand.Insert));

//Some Code
OnTransactionEnded(this, new TransactionEndedEventArgs(ItemCommand.Insert));
return s;
}

}
public virtual bool Update()
{
lock(syncObject)
{
OnTransactionStarted(this, new TransactionStartedEventArgs(ItemCommand.Update));

bool updated = false;

//Some COde

OnTransactionEnded(this, new TransactionEndedEventArgs(ItemCommand.Update));

return updated;
}

}
public virtual bool Delete()
{
lock(syncObject)
{

bool deleted = false;
OnTransactionStarted(this, new TransactionStartedEventArgs(ItemCommand.Delete));

//Some Code

OnTransactionEnded(this, new TransactionEndedEventArgs(ItemCommand.Delete));
return deleted;
}

}
}
GeneralRe: Isynchronizeinvoke question Pin
TJoe28-Sep-07 12:49
TJoe28-Sep-07 12:49 
AnswerRe: Isynchronizeinvoke question Pin
pbraun7-Oct-07 7:19
pbraun7-Oct-07 7:19 
QuestionMenu Items Pin
Ekwy21-Sep-07 1:03
Ekwy21-Sep-07 1:03 
AnswerRe: Menu Items Pin
Luc Pattyn21-Sep-07 6:32
sitebuilderLuc Pattyn21-Sep-07 6:32 
QuestionTo remove all assemblies from GAC and Native cache of a particular public key Pin
Mushtaque Nizamani20-Sep-07 18:04
Mushtaque Nizamani20-Sep-07 18:04 
AnswerRe: To remove all assemblies from GAC and Native cache of a particular public key Pin
Pete O'Hanlon21-Sep-07 2:48
mvePete O'Hanlon21-Sep-07 2:48 
Questionwhat are the best c#.net components for processing OCR and digital cameras? Pin
md.naseri20-Sep-07 7:31
md.naseri20-Sep-07 7:31 
GeneralRe: what are the best c#.net components for processing OCR and digital cameras? Pin
Paul Conrad31-Dec-07 9:25
professionalPaul Conrad31-Dec-07 9:25 
QuestionMC# programming language for multi-threaded programming Pin
YuryS200720-Sep-07 2:27
YuryS200720-Sep-07 2:27 
AnswerRe: MC# programming language for multi-threaded programming Pin
Colin Angus Mackay20-Sep-07 3:54
Colin Angus Mackay20-Sep-07 3:54 
AnswerRe: MC# programming language for multi-threaded programming Pin
Dave Kreskowiak20-Sep-07 6:46
mveDave Kreskowiak20-Sep-07 6:46 
AnswerRe: MC# programming language for multi-threaded programming [modified] Pin
Pete O'Hanlon20-Sep-07 10:26
mvePete O'Hanlon20-Sep-07 10:26 
GeneralRe: MC# programming language for multi-threaded programming Pin
Scott Dorman20-Sep-07 10:39
professionalScott Dorman20-Sep-07 10:39 
GeneralRe: MC# programming language for multi-threaded programming Pin
Pete O'Hanlon20-Sep-07 10:55
mvePete O'Hanlon20-Sep-07 10:55 
GeneralRe: MC# programming language for multi-threaded programming Pin
Scott Dorman20-Sep-07 11:05
professionalScott Dorman20-Sep-07 11:05 
GeneralRe: MC# programming language for multi-threaded programming Pin
Pete O'Hanlon20-Sep-07 11:10
mvePete O'Hanlon20-Sep-07 11:10 
AnswerRe: MC# programming language for multi-threaded programming Pin
Vasudevan Deepak Kumar25-Sep-07 7:41
Vasudevan Deepak Kumar25-Sep-07 7:41 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.