|
You will have to drop the return value in a place that is accessable by another thread. You will have to protect the storage with a mutex, also add a condition to signal the other thread that processing is done. This is needed because processes can't return things to eachother, instead they storage data that has to be exchanged in a central place that is accessable by others.
These two steps start the threads and let the first thread wait for a signal of the other thread.
Thread 1 -> Thread2.Start();
Thread 1 -> Condition.Wait();
These steps are performed by the second thread in such a way that the storage can only be accessed by one party at a time. After the second thread is done, it will signal the first thread that it's done.
Thread 2 -> Mutex.Lock();
Thread 2 -> Set some value
Thread 2 -> Mutex.Unlock();
Thread 2 -> Condition.Signal();
These last steps are performed after the first thread gets a signal that the second thread is done.
Thread 1 -> Mutex.Lock();
Thread 1 -> Get value
Thread 1 -> Mutex.Unlock();
I'm not sure to what extend Microsoft implemented threading and concurrency tools, but if you don't have the Mutex or the Condition, you can do it with a Semaphore. The same trick, except for these changes:
Thread 1 -> Semaphore.P();
Thread 2 -> Set value in storage
Thread 2 -> Semaphore.V();
Thread 1 -> Get value from storage
This classic is also called the producer/consumer scenario.
WM.
What about weapons of mass-construction?
|
|
|
|
|
Hi ,
I'm Working on dataGridView i want the datagridview to scroll to specified row
like if the row # 10 is selected i want to jump to other row like row # 1010
this easy by using dataGridView1.Rows[1010].Selected = true;
but how can i make the dataGridView to scroll to that row
Thx for ur help
Regards,
Charbel
|
|
|
|
|
Hello
MyDataGridView.FirstDisplayedCell = MyDataGridView.Rows[MyIndex].Cells[0];
Sorry! Requires .Net 2.0
Regards
|
|
|
|
|
hi all,
I have a MDIForm, contains a TreeView. I wanna set focus to a child form after I clicked a note.
But, the TreeView doesn't lost foucs. so, my question is:
how to set focus to a child form after I clicked a TreeNode?
and I googled this question, I got this:
<br />
Form newForm = this.CreateForm();
form.BeginInvoke((MethodInvoker)delegate(){form.Focus();});<br />
at MSDN Forums
but it doesn't work.
any help would be appreciate. Thanks.
|
|
|
|
|
I’m coding in C# and I am working with a COM object that I earlier in C++ made this call:
COleVariant varBeforeEnd(DISP_E_MEMBERNOTFOUND, VT_ERROR);<br />
hresult = pTemp->Add(knownObject, &varBeforeEnd );
How do I make the call in C#?
The IDE in VisualStudio say that the Add(…) function should have parameters like this:
Add(KownObject, ref object);
Any tip what to do with the second parameter? I’ve tried to block some primitive types like int and bool to an object, but I only get exceptions…
All tips are welcomed!
_____________________________
...and justice for all
APe
|
|
|
|
|
You have to use the ref keyword when you call the method, and use a variable of type Object to reference:
object o = 42;
Add(knownObject, ref o);
---
b { font-weight: normal; }
|
|
|
|
|
Found the solution:
Object obj = System.Reflection.Missing.Value;<br />
temp.Add(known, ref obj);
_____________________________
...and justice for all
APe
|
|
|
|
|
Hi everybody.
I want to write a full screen app. All that I want is a white dot on a black screen that moves up, down, left, right according to the keyboard.
Its all not complex at all if I would've done that on a window form, BUT I want to make it on a console (or whatever type of project it should be).
The problem is that I don't even know where to start to make such an application, can anyone at least give me directions where do I start? (an article maybe?).
Thanks!
|
|
|
|
|
You could look into a DirectX app. I'm shure there are some articles on this site to help you out with that.
|
|
|
|
|
Hello there,
I'm trying to create a IPCChannel connection between 2 processes on my pc. The 1 process is a Windows Service and the other a Windows app.
The windows service is the client in this case. when doing the connection an exception is thrown saying:Failed to connect to an IPC Port: Access is denied.
When I debug this windows service (run it as a normal app not as a service), the code executes fine. So does anybody why as a Service the app is not allowed to connect and how I might fix this???
Thanks for any help you provide,
Greetings,
Davy
|
|
|
|
|
I'm new to IPC but ...
Have you checked SecurityPermission attribute?
BTW if you know how to detect if IPC channels have been opened by the remote process, could you please tell me ?
|
|
|
|
|
try setting account type to user on windows service. Just a stab in the dark though. I have IPC working over a windows service with account type as user
|
|
|
|
|
Dear Friends,
I have one small C# webapplication. I want to read the value of one typical coloumn of my gridview for each row in such a way that I am checking the status for one of my ItemTemplate called as checkbox1 as below
foreach (GridViewRow row in AppGrid.Rows)
{
bool st = ((CheckBox)row.FindControl("CheckBox1")).Checked;
" Here I need code to access the value of first coloumn which is bound as pCode for the same row "
}
Your quick response will be highly appreciated.
Thanks
Murtuza Patel
|
|
|
|
|
You can retrieve values from a row by calling
String value = row.Cells[index].Text;
WM.
What about weapons of mass-construction?
|
|
|
|
|
hai all,
is there any function for SetROP2 in c#.net. i want to use this SetROP2 function in C# which will take float values in draw mode
private static extern Int32 SetROP2(IntPtr hDevice, int nDrawMode)
|
|
|
|
|
hello every one!
well I got this query here, I'm really stuck in this error. I'm working oin a master detail form in .net 2.0 C# in Windows Forms. its a System.ArgumentException that I'm getting here. I've these dataGridview on the form. I've made a typed dataset for it. the tables are these
PurchBill(PurchBillID, VendID, Bookno, BillDate)
Purch(purchID,purchbillID,Serial, ModelID, PresentAt,PurchWarranty,PurchPrice)
ProdLine
ProdModel
and vu_manNames thats a view
I've set up seperate dataGridViews for Purch, ProdLine and ProdModel and for selecting the manufacturer name here. Look at this code
private void saverecord()
{
try
{
int n = 0;
if (flagUpdate == false)
{
for (int row = 0; row < dataGridViewPurch.Rows.Count; row++)
{
DataRow dr = dsPurch1.Purch.NewRow();
dr["PurchBillID"] = sqlInsertCommandPurch.Parameters["@purchBillID"].Value = dsPurch1.PurchBill[this.BindingContext[dsPurch1, "PurchBill"].Position].PurchBillID;
MessageBox.Show("Value of Serial \n" + dataGridViewPurch.Rows[row].Cells["Serial"].Value.ToString());
dr["Serial"] = sqlInsertCommandPurch.Parameters["@Serial"].Value = dataGridViewPurch.Rows[row].Cells["Serial"].Value.ToString();
dr["PurchPrice"] = sqlInsertCommandPurch.Parameters["@PurchPrice"].Value = Convert.ToDecimal(dataGridViewPurch.Rows[row].Cells["PurchPrice"].Value.ToString());
MessageBox.Show("Value of ModelID: " + dsPurch1.ProdModel[this.BindingContext[dsPurch1, "ProdModel"].Position].ModelID.ToString());
dr["PurchWarranty"] = sqlInsertCommandPurch.Parameters["@Purchwarranty"].Value = Convert.ToDecimal(dataGridViewPurch.Rows[row].Cells["PurchWarranty"].Value.ToString());
dr["modelID"] = sqlInsertCommandPurch.Parameters["@ModelID"].Value = dsPurch1.ProdModel[this.BindingContext[dsPurch1,"ProdModel"].Position].ModelID ;
dsPurch1.Purch.Rows.Add(dr);
//MessageBox.Show("Hello");
n += daPurch.Update(dsPurch1, dsPurch1.Purch.ToString());
//refreshDataSet();
}
MessageBox.Show("Number of records inserted: " + n.ToString());
dsPurch1.AcceptChanges();
}
else
{
//this code is for the updating a record.
for (int row = 0; row < dataGridViewPurch.Rows.Count; row++)
{
if (dataGridViewPurch.Rows[row].Cells["PurchPrice"].Value.ToString().Length != 0)
{
dsPurch1.Purch[this.BindingContext[dsPurch1, "Purch"].Position].BeginEdit();
sqlUpdateCommandPurch.Parameters["@PurchBillID"].Value = dsPurch1.PurchBill[this.BindingContext[dsPurch1, "PurchBill"].Position].PurchBillID = Convert.ToDecimal(dataGridViewPurch.Rows[row].Cells["PurchBillID"].Value.ToString());
//sqlUpdateCommandPurch.Parameters["@PurchBillID"].Value = dsPurch1.Purch[this.BindingContext[dsPurch1, "Purch"].Position].PurchBillID = Convert.ToDecimal(dataGridViewPurch.Rows[row].Cells["PurchBillID"].Value.ToString());
sqlUpdateCommandPurch.Parameters["@PresentAt"].Value = dsPurch1.Purch[this.BindingContext[dsPurch1, "Purch"].Position].PresentAt = 1;
sqlUpdateCommandPurch.Parameters["@ModelID"].Value = dsPurch1.Purch[this.BindingContext[dsPurch1, "Purch"].Position].ModelID = Convert.ToDecimal(dataGridViewProdModel.SelectedRows[0].Cells["ModelID"].Value.ToString());
for (int col = 0; col < 3; col++)
{
if (col == 0)
sqlUpdateCommandPurch.Parameters["@PurchPrice"].Value = dsPurch1.Purch[this.BindingContext[dsPurch1, "Purch"].Position].PurchPrice = Convert.ToDecimal(dataGridViewPurch.Rows[row].Cells["PurchPrice"].Value.ToString());
else if (col == 1)
sqlUpdateCommandPurch.Parameters["@Serial"].Value = dsPurch1.Purch[this.BindingContext[dsPurch1, "Purch"].Position].Serial = dataGridViewPurch.Rows[row].Cells["serial"].Value.ToString();
else
sqlUpdateCommandPurch.Parameters["@Purchwarranty"].Value = dsPurch1.Purch[this.BindingContext[dsPurch1, "Purch"].Position].PurchWarranty = Convert.ToDecimal(dataGridViewPurch.Rows[row].Cells["PurchWarranty"].Value.ToString());
sqlUpdateCommandPurch.Parameters["@Original_PurchID"].Value = dsPurch1.Purch[this.BindingContext[dsPurch1, "Purch"].Position].PurchID;
sqlUpdateCommandPurch.Parameters["@Original_purchBillID"].Value = dsPurch1.Purch[this.BindingContext[dsPurch1, "Purch"].Position].PurchBillID;
sqlUpdateCommandPurch.Parameters["@Original_purchPrice"].Value = dsPurch1.Purch[this.BindingContext[dsPurch1, "Purch"].Position].PurchPrice;
sqlUpdateCommandPurch.Parameters["@Original_Serial"].Value = dsPurch1.Purch[this.BindingContext[dsPurch1, "Purch"].Position].Serial;
sqlUpdateCommandPurch.Parameters["@Original_PurchWarranty"].Value = dsPurch1.Purch[this.BindingContext[dsPurch1, "Purch"].Position].PurchWarranty;
sqlUpdateCommandPurch.Parameters["@Original_PresentAt"].Value = dsPurch1.Purch[this.BindingContext[dsPurch1, "Purch"].Position].PresentAt;
sqlUpdateCommandPurch.Parameters["@Original_ModelID"].Value = dsPurch1.Purch[this.BindingContext[dsPurch1, "Purch"].Position].ModelID;
MessageBox.Show("Position\n" + this.BindingContext[dsPurch1, "Purch"].Position.ToString());
dsPurch1.Purch[this.BindingContext[dsPurch1, "Purch"].Position].EndEdit();
n += daPurch.Update(dsPurch1, "Purch");
dsPurch1.AcceptChanges();
MessageBox.Show("Number of records updated" + n.ToString());
}
}
else
{
MessageBox.Show("Invalid Serial no");
}
}
}
//btnNavFirst.Enabled = btnNavNext.Enabled = btnNavPrev.Enabled = btnLast.Enabled = true;
}
catch (DBConcurrencyException ex)
{
MessageBox.Show("Zero records affected.\n\n" + ex.ToString());
}
catch (SystemException ex)
{
MessageBox.Show("The source table could not be found.\n\n" + ex.ToString());
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
}
}
=======================================================================
this is meant to save and update as necessary and I’m getting the error on the line I’ve made bold and it says that
System.ArgumentException: Column names Serial can not be found
Parameter name: columnName
At system.Windows.Forms.DataGridViewCellCollection.get_Item(String columnName)
I’ve set up the datamember property to u know the child of PurchBill that is the purch table. I think there are a few errors in the datagridView class (maybe).
Plz help me out of this, I think I’m getting crazy here
Thanks in advance
What I don’t understand is that I’ve done the same work for anoter form in the same fashion and its working fine. It seems to me that there is no property named with these columns here but why is this happenin? And what should I do abt it?
Rocky
|
|
|
|
|
I have written a User Control which has a button and a text box on it. The textbox is updated by using
UserControlTxtBox.Text= someValue;
This works fine if there is one User Control on a form.
If I have 2 or more, the first User Control works ok initially, but once I start to access the Text property of the TextBox on the second control, both Text properties on both controls get updated with the same information from then on. It seems to be updating the User Controls' textBox rather than the base control individually.
Any idea on how I can fix this?
Regards
alias47
|
|
|
|
|
Hello,
Are you creating the Usercontrols dynamicaly?
Do you have an instance variable for each usercontrol?
All the best,
Martin
|
|
|
|
|
hi,
i want to send/receive some commands to one hardware device through GPIB card(one end is connected to System(USB port) one end is connected to device) in c#.net .
i wnat to know in which way i can communicate the device and what r requried fields to access the hardware through GPIB card.
plz send sample code for that .
it's very usefull to in my application.
Thanks
prem
|
|
|
|
|
Hi,
I want start application from another application.
for example
if i have a,b,c,d applications.
so if i want to start a,b,c application through d application.
how to do ?
help me out.
thanks
|
|
|
|
|
Hello,
System.Diagnostics.Process.Start("filename");
All the best,
MArtin
|
|
|
|
|
thanks for help ,it's working for
but if application on remote location then?
|
|
|
|
|
Hello,
I'm not sure if I understand you right, but maybe you find youre processes with:
System.Diagnostics.Process.GetProcesses(machinename);
and then Start them over there instance.
All the best,
Martin
|
|
|
|
|
I am trying to develope a music server through which any music player can connect and play the songs and other medias,so if anyone has any idea about it ,do post me.
nishu
|
|
|
|
|
Hello Nishu,
I think this tool may helpfull to u.
Here is there audio library
regards,
Divyang Mithaiwala
System Engineer & Software Developer
|
|
|
|