|
If those are the only lock statements in the code, and they always get called in that order, it won't cause a deadlock. But if they always get called in that order, the inner lock is of no use at all.
---
b { font-weight: normal; }
|
|
|
|
|
Guffa wrote: If those are the only lock statements in the code, and they always get called in that order, it won't cause a deadlock. But if they always get called in that order, the inner lock is of no use at all.
First, the second lock(this) is not necessarily called every time, but when called the order is always the same. Second, the second lock(this) may also be called directly from other threads which have no relation to StateMachine(outside statemachine).
|
|
|
|
|
lock(this) can bring you in a deadlock
instead create a field like this:
private object syncRoot = new object();
and use
lock(syncRoot)
[EDIT] Not static field will be static only for static methods
|
|
|
|
|
Thank you very much.
lock( a private object )
was the good way introduced to avoid deadlock.
But why lock(this) brings about deadlock?
I want to find the case in which my program falls into a deadlock.
|
|
|
|
|
This article seems to mention a DeadLock
http://www.codeproject.com/csharp/lockmanager.asp
|
|
|
|
|
I need a guru's advice: I am porting datagrids over to gridviews, and have the following old code:
<br />
foreach (DataGridItem dgItem in dgClicks.Items)<br />
{<br />
CheckBox chkSelected = (CheckBox)dgItem.FindControl("chkSelection");<br />
if (chkSelected != null && chkSelected.Checked)<br />
{<br />
if (dgClicks.DataKeys[dgItem.DataSetIndex] != System.DBNull.Value)<br />
{<br />
int nTopupRequestID = (Int32)dgClicks.DataKeys[dgItem.DataSetIndex];<br />
<br />
BL.receipts.BlockCapturedTransaction(nTopupRequestID, edBlockReason.Text);<br />
}<br />
}<br />
}<br />
But I can't seem to figure out how to fix the second conditional in what I have written to convert.. I keep getting an operator overload error..
<br />
foreach (GridViewRow gvRow in gvClicks.Rows)<br />
{<br />
CheckBox chkSelected = (CheckBox)gvRow.FindControl("chkSelection");<br />
if (chkSelected != null && chkSelected.Checked)<br />
{<br />
if (gvClicks.DataKeys[gvRow.DataItemIndex] != System.DBNull.Value):confused:<br />
{<br />
int nTopupRequestID = Convert.ToInt32(gvClicks.DataKeys[gvRow.DataItemIndex]);<br />
<br />
BL.receipts.BlockCapturedTransaction(nTopupRequestID, edBlockReason.Text);<br />
}<br />
}<br />
}<br />
I'm sure this is an easy fix for some of yu guys.. so what did I do wrong? Is there a better way to approach this with the GridView??
Hoping for someones kind assistance!
-Eric
Practice sesquipedalianism!
-- modified at 8:27 Friday 24th March, 2006
LETS SHORTEN MY QUESTION.. HOW WOULD YOU WRITE THIS WITH A GRIDVIEW, NOT A DATAGRID??
if (dgClicks.DataKeys[dgItem.DataSetIndex] != System.DBNull.Value)
|
|
|
|
|
I have a problem about lock in C#.
I have written a multithread program, but the other day, the program hung up suddenly.
I have checked the code throughly but i could find nothing wrong.
In order to realize sync., i use lock(this) at several places.
But to my dismay, i was told this is not a good way at all recently.
Can anyone give me some information about this?
Thank you
-- modified at 6:57 Friday 24th March, 2006
|
|
|
|
|
Who told you that it wasn't a good way, and what was the arguments for that?
Locking should of course be kept as a minimum, and to avoid deadlocks a thread should never lock more than one object at a time. Still, for sharing data between threads there is hardly any alternative.
---
b { font-weight: normal; }
|
|
|
|
|
Why this methid AcceptTcpClient() takes much time to connectd and i can't connect.
Any idea????
_____________________
Proud to be Albanian
_____________________
|
|
|
|
|
Looks like your client is not trying to connect properly.
Ed
|
|
|
|
|
I never had that experience. Maybe something wrong with your code!
---
With best regards,
A Manchester United Fan
The Genius of a true fool is that he can mess up a foolproof plan!
|
|
|
|
|
Hi,
I need to read a csv file...I m using OleDB Connection for this i have done this code...
OleDbConnection conCSV = new OleDbConnection( "Provider=Microsoft.Jet.OLEDB.4.0;" + "Data Source=" + dirName + ";Extended Properties='Text;HDR=Yes;FMT=Delimited;IMEX=1'" );<br />
<br />
OleDbDataAdapter daDBF = new OleDbDataAdapter<br />
( "SELECT * FROM " + fileName, conCSV );<br />
<br />
daDBF.Fill( DS, "Bids" );<br />
<br />
DS.WriteXML( TestFilePath );
But I m not Getting Full Data out, From CSV file some of the Data gets Truncated On Server It's Working fine On My local Machine...
Can Anybody sort out this...Pls
Thanx & Reagards
Anuj Kamthan
Software Developer
Solversa Technologies,
Pune - 411007, India.
http://www.solversa.com
-- modified at 6:11 Friday 24th March, 2006
|
|
|
|
|
See if you can do something like daDBF.CommandTimeOut(3000); or something.
You should set the OleDBCommand.CommandTimeout setting higher than the default 30 seconds first t see if it rectify's the situation..
Practice sesquipedalianism!
|
|
|
|
|
Thanks a lot for your interest
But Problem is different it's not because of timeout...
When i m reading the csv file and filling it in to dataset...whole records ll copied in to dataset but, there is an column in my csv file "Description" only this column's data ll truncate if it's very big...
Is there any limit in dataset...Can't save more then 255 character in a column.
Thanx
Anuj Kamthan
Software Developer
Solversa Technologies,
Pune - 411007, India.
http://www.solversa.com
|
|
|
|
|
I need C# Code to Show/Hide Quick Launch Bar.
|
|
|
|
|
Dont repost, you asked this yesterday... you will need to look in the WinAPI somewhere. I dont know where.
|
|
|
|
|
Hi..
How do i load the textfile i open into a richTextBox?
The best thing for me would be if i save this directory path that i choose in a "config file" so it saves there. Second i want to browse the text file (.scp) in my richTextBox.
<br />
private void btnOpen_Click_1(object sender, EventArgs e)<br />
{<br />
OpenFileDialog fdlg = new OpenFileDialog();<br />
fdlg.Title = "Emu Open File Dialog";<br />
fdlg.InitialDirectory = @"c:\";<br />
fdlg.Filter = "Emu Files (*.scp*)|*.scp*|Emu Files (*.scp*)|*.scp*";<br />
fdlg.FilterIndex = 2;<br />
fdlg.RestoreDirectory = true;<br />
if (fdlg.ShowDialog() == DialogResult.OK)<br />
{<br />
textBox20.Text = fdlg.FileName;<br />
}<br />
Anyone that can help me?
Regards
//Aeq...
|
|
|
|
|
You want to display the text of the .scp file into
the richtextbox , right?
This should work for u.
OpenFileDialog opdf = new OpenFileDialog();
opdf.ShowDialog();
richTextBox1.LoadFile(opdf.FileName,RichTextBoxStreamType.PlainText);
Hope that works fine for u
Regards,
Pramod
|
|
|
|
|
Hey guys, i'm wondering how I can bind DataGrideView to dataset, like data gride. so for instance when i click on a record in my DataGriedView I can have it in some Text Boxes for exiting.
Thanx
Mr.K
|
|
|
|
|
Like the GridView, the DetailsView control can bind to any data source control and exploit its set of data operations. It can page, update, insert, and delete data items in the underlying data source as long as the data source supports these operations. In most cases, no code is required to set up any of these operations. You can customize the user interface of the DetailsView control by choosing the most appropriate combination of data fields and styles in much the same way that you do with the GridView. Finally, the DetailsView control fully supports adaptive rendering and renders successfully on mobile devices.
The DetailsView control deliberately doesn’t support templates. A fully template based details-view control is the FormView. FormView is a new data-bound control that works like the templated version of the DetailsView. It renders one record at a time picked from the associated data source and optionally provides paging buttons to navigate between records. Unlike the DetailsView control, FormView doesn’t use data control fields and requires the user to define the rendering of each item using templates. The FormView can support any basic operation its data source provides.
In ASP.NET 2.0, data sources, GridView, and DetailsView controls enable a no-code master/detail scenario. A master/detail page contains a master control (such as a GridView) and a detail control (such as a DetailsView), each bound to its own data source. The trick is in binding the detail control to a data source represented by the currently selected record.
Practice sesquipedalianism!
-- modified at 8:17 Friday 24th March, 2006
|
|
|
|
|
Hi,
I've already asked this before in this forum, but I still have the same problem.
I hope somebody can help me. (I've tried google and msdn)
I've wrote a wrapper for a COM module. Some parameters for the COM functions need to be passed by-value:
(long*, BSTR*, ...)
I've tried round about everything, but I always get a type mismatch error (0x80020005, DISP_E_TYPEMISMATCH)
(ref string, normal strings, with the [MarshalAsAttribute(UnmanagedType.BStr)] attribute, with unsafe keyword etc...) I also tried to change longs of the COM module to ints
here's a sample of one of the wrapped methods:
<br />
unsafe public int GetDlgText(int dlgid, int fldid, int row, int col, [MarshalAsAttribute(UnmanagedType.BStr)] string text){<br />
int returnvalue = -1;<br />
try{<br />
object[] cmds = { dlgid, fldid, row, col, text };<br />
returnvalue = Convert.ToInt32(Interaction.CallByName(idisp, "GetDlgText", CallType.Method, cmds));<br />
}
catch(Exception e) {<br />
lasterrormessage = "Could not invoke GetDlgText function: " + e;<br />
}
return returnvalue;<br />
}
the documentation says it's like this: long GetDlgText(long DlgId, long FldId, long Row, long Col, BSTR* Text);
What on earth could be the problem?
Tnx!!
Coulda, woulda, shoulda doesn't matter if you don't.
|
|
|
|
|
Hi!
I've sort of followed the replies you got before and they seemed to be very reasonable...
1.) You absolutely MUST marshal the C++ long parameters als int in .NET. If you don't do this then the offset for everything else on the stack is off, no matter what you use to marshal the BSTR*.
2.) Don't know why you're using the unsafe keyword in the declaration above - try removing it
3.) You could try removing the MarshalAs attribute altogether and put in a StringBuilder as the las parameter.
Regards,
mav
--
Black holes are the places where god divided by 0...
|
|
|
|
|
Hey,
Tnx for your reply.
Sure they were reasonable, I've tried about everything I could find on the I-net and here on CP (including what you just replied).
Still the same error.
tnx for the effort though.
Coulda, woulda, shoulda doesn't matter if you don't.
|
|
|
|
|
Thank u for the response for the last post....Now My problem is...
I want to keep track of all the users who are accessing my application, this is in intranet environiment.All the users who are accessing the application must able to see the names of all users who are using the application.How to achieve this....
|
|
|
|
|
Do you have a login system?
--------------------------------------------------------
Q:What does the derived class in C# tell to it's parent?
A:All your base are belong to us!
|
|
|
|