|
You can use null then can bind the next datasource. But it seems that you already tried that. Ok. just call Refresh() methos of your control just before binding second datasource.;)
Sreejith Nair
[ My Articles ]
|
|
|
|
|
I need a little guidance on a multithreaded application. The idea of the app is to have a machine send UDP packets to a server and the server will retrive the packets, parse out the data, and submit to a DB. I am initially looking at this as a multithreaded approach with the server being separated into 2 threads: 1) UDP retrieval, and place message into message queue, 2) send message from queue to DB.
i.e.
Class retriever
{
public retrievemsg()
{
while(true)
{
lock(queue)
{
//retrieve message and place on queue
}
}
}
}
Class Sender
{
public sendToDB()
{
while(queue not empty)
{
lock(queue)
{
//send msg info to DB
}
}
}
}
While I understand the concepts of multithreading and concurrency and the such, what I am having trouble with is since the threads are basically always running how will the CPU know to switch threads to execute the one that needs processing. For example, the UDP packets are going to arrive pretty regularly, but we still want regular service of the packets and the infomration should show up regularly into the DB. I don't want to explicitly say Thread.Sleep(0) because I am not exactly sure when is the best time, or it could change. How would I synchronize the running of these threads.
Thanks ahead of time
|
|
|
|
|
Your problem is the typical Producer-Consumer problem. One thread writes to the queue and the thread needs to know when the queue is not empty. You can use the AutoResetEvent class or the Monitor class to do the synchronization. Typical code will look like
Class retriever
{
public retrievemsg()
{
while(true)
{
lock(queue)
{
queue.Add(msg);
Monitor.Pulse(queue);
}
}
}
}
class Sender
{
public sendToDB()
{
lock(queue)
{
while(true)
{
Monitor.Wait(queue);
Msg msg = queue.Remove(msg);
}
}
}
}
You can also use the AutoResetEvent to signal the Sender that a message has arrived. The Sender will WaitOne() on the event and once signalled, will fetch the item.
Regards
Senthil
My Blog
|
|
|
|
|
Just my $0.02
UDP? Shouldn't you be using TCP instead? UDP makes no guarantees about the packets getting to their destination, let alone the order in which they get there! If you're adding information to a database, usually you want consistancy in the data that's going into it. TCP would be a much better choice, particularly over the Internet.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
I own a charting application with a horizontal scroll bar that can be slid from side-to-side to view the entire chart (normal scrolling action). This scroll bar also has a grip at each end that can be used to expand/shrink its length, and thus expand/shrink the scope of the current viewing area (resulting in a zoom-in, zoom-out action).
Is this dual-action scroll bar built from a set of "stock" functions in .NET, or does it require a fully customized approach?
I would like to recreate this control in C#, and I would appreciate any information or example(s) that could help get me started. Thanks.
|
|
|
|
|
I think using frames can solve ur problem..by giving default size and scrolling properties u can get those two featurs mentioned by u in the query.
And rather than using any other customised controls, using frames in which ur chart resides will fulfill ur requirment.
As got lil busy with work..not able to send u any examples
|
|
|
|
|
Gamya,
Thank you for your response.
The charting application and the C# project that I am building are both Windows applications. As I understand, frames are useful only with Web based applications. Is this true?
Dennis
|
|
|
|
|
Hai
U r right..The frames concept can be applied only in Web apps..And As for windows apps..u have Horizontal and vertical scroll bars readily in ur tool box. U can use them in ur apps and write events as appropriate..
And there are plenty of articles avaliable in net about the usage of Scroll bars..And dont have any idea abt resizing the chart..
Regards
Gamya
|
|
|
|
|
Thanks Gamya.
I'll keep researching this. If I find any resizing/zoom info relating to scroll bars, I will post back to this thread.
|
|
|
|
|
And just now i found out that thru panels we can have the autoscroll set to true..
|
|
|
|
|
Cripes...I'm working up a very rudimentary database app with data-bound controls: load all records to datagrid and user can filter results by choosing elements from lists.
Problem: during app initialization, a button to reload datagrid with filtered results is being clicked repeatedly. I've isolated the routine in another function (not in button_click), and it is fired ~20 - 30 times during startup.
Any ideas on how/why this is happening?
|
|
|
|
|
Please check your code clearly and make sure databinding takes place in one place , which need to be after Initialization(). If you can show me, that cose block, then that will be very nice to trace the issue.;)
Sreejith Nair
[ My Articles ]
|
|
|
|
|
Thanks for the feedback. As usual, providing details will help the analysis.
Yes, I have placed all the databinding after Initialization(). The 'load-filtered-data' button has only one statement: a call to a dataview filter routine. In this routine I build a filter statement, using the selected list item:
private void Filter(string comboString)
{
string filterString;
filterString = "EngrName='" + comboString + "'";
DataView myDataView = new DataView(workordersDataset1.Tables["WorkOrders"]);
myDataView.RowFilter = filterString;
this.dataGrid1.DataSource = myDataView;
this.dataGrid1.Refresh();
}
If I remove the call to this function and re-compile, my datagrid loads with all records -- exactly what I want. If I leave in the function call, the datagrid is blank, and the button_click &/or the filter function do not fire. I haven't built any error handling yet, and I'm sure that would help me to troubleshoot.
Thanks very much.
|
|
|
|
|
Hai,
I want to add , delete , update my details
say my form has
name:
domain:.net,java
exp..
I wnt these things to add/del/update into my db.
also i wnt search option to say
domain:dotnet exp :2+
from db all the persons meeting the key words shouls come with there entire profile.
in the profile area i also wnt to add a option to see my resume.
kindly some give me code for the above things
chand
|
|
|
|
|
To add, delete, or update, try
http://www.codeproject.com\useritems\ado.asp[^]
You should learn about SQL, if you haven't.
To search for person, you can use the query:
Select * from member where domain=dotnet and exp>1
Good luck.
<italic>Work hard and a bit of luck is the key to success. You don`t need to be genius, to be rich.
|
|
|
|
|
Hi,
I have created an Arraylist object from an Arraylist class.
I added rows to the arraylist object and I need to find a particular record in my arraylist. How do I do this? Also if I was in the middle of building the arraylist and wanted to call the last record added to arraylist object how can I do this?
Thanks,
JJ
|
|
|
|
|
You can get the index of the object using thhis syntax:
ArrayList a = new ArrayList();<br />
a.Add("a");<br />
a.Add("b");<br />
int objectArrayIndex = a.IndexOf("a");
If you just want to access the object with the highest index:
string myString = (string)a[a.Count - 1];
Remember, it's a 0 based array, so subtract 1 from the Count property
|
|
|
|
|
Hi,
i have developed a application using c#.net . kindly tel me how to setup the project
please kindly give me the steps i have to follow.
i.e how to upload(r setup ) my whole application.
so tht i can give it to cilent . r make software
kindly reply
chand
|
|
|
|
|
In your Visual Studio.NET Solution Explorer, right click your solution and choose the Add option and select New Project. Now select the Setup and Deployment Projects folder icon. Pick the project that targets your code (i.e. win forms or web).
There are plenty of good tutorials if you search on Google.com
try This Tutorial[^] for starters
|
|
|
|
|
Hi. I'm using the "File.Move" method in the System.IO namespace. When I start my program and call this method it executes no problem. The second time I call it I am getting and error message saying "Exception: The process cannot access the file ... because it is being used by another process".
When I close the program and run it again the method runs fine, again for the first time.
I would think the connection is just not closing for some reason. Does anyone know how I can fix this?
|
|
|
|
|
Well, you could try calling dispose() on your object to see if it would help. My guess is your problem is somewhere else. Are you using any FileStreams ? You definately need to close those by explicitly calling Close() on them. Post some more code if you can...
-Peter
|
|
|
|
|
Not enough information. Move what file? Is your application writing it? Are you holding it open? Where does this file come from that your trying to move?
The problem is obvious - "being used by another process". This means that you can't move a file that is open for reading and/or writing. So what has the file open?
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
My data adapter wizard will not configure a table with more than 100 columns. Is there a way to get it to do so? I have tried to manually configure bt I get a syntax error message when I exceed 100 columns. Thanks
Mark
|
|
|
|
|
Do you have the ability to cut down on the number of columns in your table? 100 columns in a single table isn't a good idea.
|
|
|
|
|
I could spit the table into smaller related tables but i will still need to update 118 columns at the same time. It appears that 100 is the limit for a data adapter.
|
|
|
|