|
|
Hello. I have an issue. I need to turn on wireless/gprs (like using wrlsmgr or wirelessmanager.exe) and configure them (ips, gateway - for wireless, and apn, login, password - for gprs). I'm using a Windows Mobile 6 PDA and VS2008.
Sorry for the poor english.
Any kind of help would be appreciated. Thank You.
Fabio Lopes
|
|
|
|
|
|
Prezado Fabio Melo,
Me chamo Rodrigo Araújo e estou na mesma situação que seu post descreve.
Apesar de ser de setembro de 2009, resolvi me cadastrar no code project só pra te perguntar se vc conseguiu resolver a questão.
Eu estou desenvolvendo para WM6 com C# e preciso detectar e ligar/desligar a wifi do dispositivo via código.
Mesmo depois de tantos meses, não acho nenhuma solução na net.
Vc conseguiu resolver de alguma forma?
Muito obrigado.
Rodrigo Araújo
|
|
|
|
|
Hello to every body.
My name is Christian and i´m not a c# developer (I´m a VFP developer) but some how i manage to built a little UDP server listener app in c#.
I needed to do this becouse I will have several vehicles that send a data via GPRS to the server each minute and the server should be listening and decode the data to store in the database (MySql). There will be hundreds of entries per minute. I Hope that somebady can tell me if my code is multithread or not and if it´s not, how can i implement it. Also, if i need multithread in the database part. The source code is in this link:
http://www.mediafire.com/file/kze3zztjzve/httprequest.rar[^]
|
|
|
|
|
Welcome to CP!
Christian_V_V wrote: The source code is in this link:
http://www.mediafire.com/file/kze3zztjzve/httprequest.rar[^]
This is not how CP works. People hardly download code. You can post the relevant code here and ask about doubts.
Christian_V_V wrote: There will be hundreds of entries per minute
There are many things to consider when implementing a highly scalable server application. Few of them are,
- How much users will be connected simultaneously? If this is more than 50, you are better off with asynchronous methods. It allows to create highly scalable applications. If you have less number of users, asynchronous methods will add unnecessary complexity to your program.
- Are you starting new thread for each client? If yes you will run into problems. You need to use a
ThreadPool . I have once written a highly scalable server with a custom thread pool taken from Smart Thread Pool[^]. - From my experience, I found it is best to work directly with
Socket class rather than the wrapper class like UdpClient . - If you need to keep reference to the clients that are connected, you should consider using a data structure that will allow faster searches. In .NET,
Dictionary class is good and it allows searching in O(1). You will find this[^] MSDN article helpful.
Christian_V_V wrote: Also, if i need multithread in the database part.
Databases are already multi-threaded. What do you meant by that?
|
|
|
|
|
Hello.
I have not found any information on this part as of yet, and I need a little bit of help.
What I have done is I have my base class that has a bunch of properties and for each property I have a attribute on it. I have other classes that will inherit this class
<pre>public abstract class MyBaseClass : IEnumerable
{
protected bool m_TableName;
protected Guid m_ID;
protected string m_DisplayName;
//CustomProperty is in the format "Field Name", Display in the grid, Database field
[CustomProperty("TableName", false, true)]
public string TableName
{
get{return m_TableName;}
set{m_TableName = value;}
}
[CustomPropety("ID", false, true)]
public Guid ID
{
get{return m_ID;}
set{m_ID = value;}
}
...
}</pre>
Now here is my next class which will be where I store my collection of classes
<pre>public abstract class MyTableObject<T> : IEnumerable<T> where T: MyBaseClass
{
protected List<T> m_Rows = new List<T>();
protected SQLConnection m_conn;
//other methods and variable not needed for my example
...
protected AddNewRow(T newItem)
{
m_Rows.Add(newItem);
}
protected FillData(SQLCommand newCmd)
{
DataTable dt = New DataTable();
using(SqlDataAdapter da = new SqlDataAdapter(newCmd))
{
da.Fill(dt);
foreach(DataRow dr in dt.Rows)
{
AddNewRow(???);
//now what I need to do is basically a T tmp = new T(); AddNewRow(tmp);
//but you can not do that it errors out.
//other code under her for adding all the fields.
//Also have a similar one for building a select statement, base insert, base update statements
}
}
}
}</pre>
Any help on this would greatly be appreciated.
The MyTableObject is the base object that all my other table object will inherit so I do not want to do the fill code at any higher lever
Thanks
modified on Tuesday, September 8, 2009 8:05 PM
|
|
|
|
|
What error do you get exactly ?
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
I'm afraid some of the type specifiers (such as <T> ) are missing in the code you have shown; to prevent the browser from interpreting them (they look like HTML tags), you should replace < by < (which happens automatically when you click the < widget on top of the edit box).
Feel free to edit and fix your orginal post.
|
|
|
|
|
Daniel.J.A wrote: //now what I need to do is basically a T tmp = new T(); AddNewRow(tmp);
You need to add a new() .
public abstract class MyTableObject<T> : IEnumerable<T> where T: MyBaseClass, new()
{
}
|
|
|
|
|
Thanks you all the ,new at the definition of the class worked.
|
|
|
|
|
hi i want know how build my own components with C# for my program but i dont have much knowledge with C# some one can tell me how i do?
thanks!
|
|
|
|
|
Well, first of all, I'm not sure what you mean exactly. A button that drop a menu ? That's an item you can add to your form. Second, if you 'don't have much knowledge', then you should buy a book and work through it, so you learn to program instead of just hoping that people online will give you code you can copy and paste blindly.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
I have been working on this issue for a few hours and finally found a work-around. This is not a pressing issue, but I am curious about getting more info. I also wanted to share my findings in case anybody else struggles with this. If you have a few minutes and you're curious too, read on...
Here are the steps to reproduce:
The first steps to set up and show a working situation...
1) Create new C# Class Library project
2) Build solution
3) Go to Data -> Add New Data Source...
4) Select Object and click Next
5) You should be able to browse to the Class1 class
Steps to cause the issue...
6) Create new folder and name it 'a'
7) Drag Class1.cs into 'a'
8) Rebuild solution
9) Go to Data -> Add New Data Source...
10) Select Object and click Next
11) The list of objects is empty while it shouldn't be
Steps to fix it again...
12) Add new class (accept default name)
13) Rebuild solution
14) Go to Data -> Add New Data Source...
15) Select Object and click Next
16) Both Class1 and Class2 show up in the list
The oddest thing...
17) Remove Class2.cs
18) Add empty text file
19) Rebuild solution
20) Go to Data -> Add New Data Source...
21) Select Object and click Next
22) Class1 show up in the list
The conclusion is that you must have a file in the top level directory of a project, or otherwise you cannot add an object data source. In my project, I just added a dummy class in the top level for now, because I have nothing useful to put in the top-level folder right now.
Another conclusion is that this has nothing to do with the namespace of the class or the default namespace of the project. You can put Class1 in namespace xxx.yyy, and it will still be found, as long as there is a file (ANY kind of file) in the root.
My questions to you are:
* Can you reproduce this issue?
* Is there any reasonable explanation for this?
* Do you consider this a bug in Visual Studio?
* If so, is this a known issue? Any references?
Thanks,
Martijn
modified on Tuesday, September 8, 2009 6:25 PM
|
|
|
|
|
I am using Microsoft Reporting services (locally).
I have a subreport which works by itself. The report has several parameters, which I programmically pass. I want to embed this report into another report. I added it as a subreport to the main report using the designer.
What code behind do I need? How do programming pass the parameters to the subreport?
Thanks
Marc
|
|
|
|
|
I'm very rusty in this area but I'm positive you can link the sub reports parameter to the main parameter without using code.
|
|
|
|
|
Hello,
I have been working on a new project of a newtork game by this method:
http://www.codeproject.com/KB/game/eatergame.aspx
I was trying to create a trivia game including 4 answer and 15 second to answer each one. for that
I have created a Question class.
The problem started While I had to create a shared time(to make sure all the clients will have the
same time as the server) so I used an extra listening thread in the Question class(it comes from
showdialog());
Everything works fine , until the 4th,5th question (something the 3rd) when the Question class
(which is a form by itself) loads too slow (like 10 sec) when the timer is already done.
I was thinking to create a Show() method instead of ShowDialog and use the Server class but it
won't work because of multithreading(It's stuck).
I would like to add I used two function I saw in net:
"threadname".abort()
"threadname".join()
also I tried to give the Question variable (which created each time in a thread) a null value and use
GC.collect()
I'm stuck , I hope someone can help me(if something isn't clear I can send you the SLN (source)
file).
Thanks alot!
|
|
|
|
|
Stop using Thread.Abort. It's bad. And GC.Collect is mostly useless - why are you using it?
|
|
|
|
|
Nothing you said is clear, except you used a lot of bad stuff and it doesn't work.
Don't send anything to anyone, simplify your code i.e. make it (almost) work without Thread.Abort
and without GC.Collect, make sure your threads terminate naturally and objects that have a Dispose() method get disposed; it problems persist, show the essential part(s) of your code.
Also make sure to catch and deal with all exceptions and log their Exception.ToString().
|
|
|
|
|
Thanks for the answers but I didn't understand some:
first of all how can i make sure a thread is being closed automatically?
second, I removed all the GC.collect, the Thread.abort and the code looks fine, I'll show you a piece:
Server:
doClientMove(){
timer = 15;
Random questionSend = new Random();
string qID = "ID:" + questionSend.Next(1, 5).ToString();
q = new Question(int.Parse(qID.Substring(qID.IndexOf(":") + 1, qID.Length - (qID.IndexOf(":") + 1))),host);
host.c.sendObject(1, q._questionString + "$" + q._questionAnswer + "$" + q._questionMis1 + "$" + q._questionMis2 + "$" + q._questionMis3 + "$" + q._rightAnswer + "$");
}
it creates a question , sends it to Client and wait to get back a sign to open a question by itself.
The Question:
Thread for the server constructer;
private void f1()
{
while (1 == 1)
{
if (_gameStart == 1)
{
int i = 15;
while (i > 0)
{
a.Text = i.ToString();
Thread.Sleep(1000);
i--;
host.c.sendObject(1,"PSYDOWN");
timer--;
}
_gameStart = 0;
this.Close();
}
}
}
Thread for the client constructer
private void f2()
{
while (1 == 1)
{
if (_gameStart == 1)
{
int i = 15;
while (i > 0)
{
a.Text =timer.ToString();
i =timer;
//a.Text = i.ToString();
//Thread.Sleep(1000);
//i--;
}
_gameStart = 0;
this.Close();
}
}
}
//server listening until the timer is over.
public void listening()
{
IFormatter form = new BinaryFormatter();
object geting = null;
ntStr.Flush();
string move;
while (timer>0)
{
if (ntStr.DataAvailable)
{
geting = form.Deserialize(ntStr);
move = (string)geting;
if (move == "PSYDOWN")
{
timer--;
}
}
}
}
What's wrong? Maybe I shouldn't share a timer? just open to each form a diffrent timer and hope it will sync?
Please , I am stuck ; what can i do??
|
|
|
|
|
Okay I found the problem:
Instead of creating a listening thread of the Server Question Class to share the timer between the Clients , I just added a timer inside The question class itself without any thread sharing it.
I mean a question is being opened with a timer instead of waiting for a value each sec from the host.
I don't understand too much in Net , could it be that although two timers start at the Question Class - one of the server and the others of the client wont be sync? (If someone lags or something)?
|
|
|
|
|
Hi,
a thread terminates when its main method returns, i.e. when all its work is done. And that should be the normal way for thread termination.
I'm not sure what YOU mean by timer, your code seems to hold some variable called "timer" which gets decremented; however that is not a timer, a timer would be an instance of Windows.Forms.Timer, Windows.Threading.Timer or Windows.Timers.Timer, i.e. some object that increments or decrements automatically at regular intervals and offers some special functionality, e.g. executing a handler.
And I did not really work my way through your code as it lacks PRE tags and formatting (indentation).
|
|
|
|
|
plz help me im preparing a web page contaning Name, Address, City (DrpDwnList), Country(DrpDwnList),.i want taht when im clkng on country's drpDwnLst then city's ddl should change automatically. so what code i wrote on Pageload, city drpdnlist' selected index chang.
plz help me
|
|
|
|
|
Start by reading this[^]
C# is not subject, it's the forum you are in. Also, your question seems to apply to ASP.NET; there is a forum for that.
only two letters away from being an asset
|
|
|
|
|
Friend,
No one has so much free time to write your code. If you want there are people here [^]who would write a loads of code for you.
I would suggest you to buy a book and start reading. That would help you in a longer run.
There are tons of tutorials, articles on internet available for it too.
You can also take a look here [^]to get started.
Manas Bhardwaj
Please remember to rate helpful or unhelpful answers, it lets us and people reading the forums know if our answers are any good.
|
|
|
|