|
Apologies for the shouting but this is important.
When answering a question please:
- Read the question carefully
- Understand that English isn't everyone's first language so be lenient of bad spelling and grammar
- If a question is poorly phrased then either ask for clarification, ignore it, or mark it down. Insults are not welcome
- If the question is inappropriate then click the 'vote to remove message' button
Insults, slap-downs and sarcasm aren't welcome. Let's work to help developers, not make them feel stupid..
cheers,
Chris Maunder
The Code Project Co-founder
Microsoft C++ MVP
|
|
|
|
|
For those new to message boards please try to follow a few simple rules when posting your question.- Choose the correct forum for your message. Posting a VB.NET question in the C++ forum will end in tears.
- Be specific! Don't ask "can someone send me the code to create an application that does 'X'. Pinpoint exactly what it is you need help with.
- Keep the subject line brief, but descriptive. eg "File Serialization problem"
- Keep the question as brief as possible. If you have to include code, include the smallest snippet of code you can.
- Be careful when including code that you haven't made a typo. Typing mistakes can become the focal point instead of the actual question you asked.
- Do not remove or empty a message if others have replied. Keep the thread intact and available for others to search and read. If your problem was answered then edit your message and add "[Solved]" to the subject line of the original post, and cast an approval vote to the one or several answers that really helped you.
- If you are posting source code with your question, place it inside <pre></pre> tags. We advise you also check the "Encode "<" (and other HTML) characters when pasting" checkbox before pasting anything inside the PRE block, and make sure "Use HTML in this post" check box is checked.
- Be courteous and DON'T SHOUT. Everyone here helps because they enjoy helping others, not because it's their job.
- Please do not post links to your question into an unrelated forum such as the lounge. It will be deleted. Likewise, do not post the same question in more than one forum.
- Do not be abusive, offensive, inappropriate or harass anyone on the boards. Doing so will get you kicked off and banned. Play nice.
- If you have a school or university assignment, assume that your teacher or lecturer is also reading these forums.
- No advertising or soliciting.
- We reserve the right to move your posts to a more appropriate forum or to delete anything deemed inappropriate or illegal.
cheers,
Chris Maunder
The Code Project Co-founder
Microsoft C++ MVP
|
|
|
|
|
Hi
I am trying to use Parallel.ForEach with ConcurrentBag and it work but to display a feedback I used progessbar control to display fname value , problem after few seconds I get error and the error message is not visible instead a wight box appear because of using a thread . any idea what is the problem in this code ?
int row_idx = 1;
ConcurrentBag<(int, string, float)> bag = new ConcurrentBag<(int, string, float)>();
Parallel.ForEach(elements, element =>
{
string fname = element.name;
float ftrack = (float)(element.track);
var elementsToAdd = new (int, string, float)[]
{
(row_idx, fname, fsize)
};
bag.Add(elementsToAdd[0]);
row_idx++;
ProgressBar1.Text = fname;
ProgressBar1.Update();
});
|
|
|
|
|
That's because you cannot touch a UI control from anything other than the UI (startup) thread. When you use tasks, you're using other threads that are not the UI thread.
To change the text of a control, you have to marshal a call to a function back to the UI thread so that function updates the Text property and does it on the correct thread.
You can see how it's done at How to make thread-safe calls to controls - Windows Forms .NET | Microsoft Learn[^]
|
|
|
|
|
|
Hello everyone,
I'm currently working on a C# project that processes a large dataset. While my code works correctly, it's running slower than expected, especially with bigger files. I'm looking for advice on optimizing the performance.
Here’s a brief overview:
-I'm reading data from a CSV file.
-Processing involves several nested loops and string manipulations.
-Writing results to a new file.
I've tried using Parallel.For for the loops but it didn't improve much. I suspect the string operations might be the bottleneck. Does anyone have suggestions on more efficient data handling or alternative approaches for processing large datasets in C# ? Any tips on using memory more efficiently or reducing execution time would be greatly appreciated.
Thank you in advance for your help.
Best regards,
Steve
tensorflow
modified 19hrs ago.
|
|
|
|
|
off to the C# forum you go
Charlie Gilley
“They who can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety.” BF, 1759
Has never been more appropriate.
|
|
|
|
|
Aside from posting your question in the correct forum - did you somehow miss the repeated "no programming questions" warnings at the top of the page? - the only thing we can suggest based on such a vague description is that you profile your code to find out where the actual bottleneck is.
Anything else is going to be a wild stab in the dark, with very little chance of success.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Profile.
CI/CD = Continuous Impediment/Continuous Despair
|
|
|
|
|
|
As has been mentioned, this is not the right place for programming queries - post your request here instead: C# Discussion Boards[^]
But ... Think about a few things first.
1) Remember that we can't see your screen, access your HDD, or read your mind - we only get exactly what you type to work with - we get no other context for your project.
Imagine this: you go for a drive in the country, but you have a problem with the car. You call the garage, say "it broke" and turn off your phone. How long will you be waiting before the garage arrives with the right bits and tools to fix the car given they don't know what make or model it is, who you are, what happened when it all went wrong, or even where you are?
That's what you've done here. So stop typing as little as possible and try explaining things to people who have no way to access your project!
Have a look at this: Asking questions is a skill[^] and think about what you need to know, and what you need to tell us in order to get help.
2) Parallelism isn't a "magic bullet" which automagically speeds up your code: it's is a complicated subject and it's very simple to slow an app down if you don't understand what you are doing.
3) The first part of speeding up an app is identifying where bottlenecks occur: if you are guessing (and "I suspect ..." is a good clue that you are) then you are very likely to chase off down a blind alley making tiny gains in performance but ignoring the "slow code". Profile your app and find out what is actually taking time!
4) We can't tell you "do this and your code will be faster" without understanding your code - and nobody wants to wade through a whole app looking for performance gains: we are all volunteers and most of us have paying job to do!
So show us code fragments that we actually need to see - without those, we are just whistling in the dark!
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
It sounds mildly interesting. More specifics would help.
|
|
|
|
|
The terms "nested loops" and "performance" do not belong in the same sentence.
If you're nesting loops in what is supposed to be high-performance code, you're killing performance of that code.
|
|
|
|
|
A bit late to the party, but here are a few thoughts.
String manipulations are as you say possibly the most likely bottleneck. Strings are immutable in C# (they don't change), so if you concatenate two strings it involves copying the data from both of them into a new string. If you're doing this in a tight loop there's going to a lots of work (and garbage collection) involved. For building up strings, StringBuilder is the class of choice, and for substrings etc. you could look at Span<char> s (C# - All About Span: Exploring a New .NET Mainstay | Microsoft Learn.
If your files are large, take a streaming approach. For instance File.ReadAllLines() loads everything into memory where as File.ReadLines() returns an iterator where you just deal with the current line. Reading a massive file into memory often isn't a great idea.
With those in place, the only other thing I can think of is pipelining. Have one thread read the input file and present records via a queue to a processing stage which processes them and then submits them via a queue to a writing stage. All these stages can run concurrently. TPL dataflow is the thing for this.
Finally, if you are using Parallel processing for nested loops, make sure you do it on the outer loop. There is overhead in parallelising work and you get better performance that way.
It's all rather difficult to say without seeing the code!
Regards,
Rob Philpott.
|
|
|
|
|
how to get repository user list and and user group from Azure DevOps
arjun
|
|
|
|
|
Google is your friend: Be nice and visit him often. He can answer questions a lot more quickly than posting them here...
A very quick search using your question as the search term gave a shed-load of responses: how to get repository user list and and user group from Azure DevOps - Google Search[^]
In future, please try to do at least basic research yourself, and not waste your time or ours.
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
If you think that Google always, without exception, provides useful, easily understandable guidance for a person who is new to a problem area, then you have only asked Google to be reminded of answers you already know.
I have several times done serious attempts at deciphering hieroglyph explanations provided by Google, without success. Even if I tell about my googling efforts, I have had people yell back to me "Why don't you just f*** google it???" To satisfy that kind of "helpers", I would have to spend twice as much space on all details of my googling as on explaining the problem.
And honestly: I believe that those spending energy on shouting "Google it!" would never spend energy on providing truly helpful assistance.
When, in meatspace, I ask coworkers or friends for help with something, some information I need, they never yell back at me: "Google it!" They treat me as a friend in need of help, not as a misbehaved child.
Religious freedom is the freedom to say that two plus two make five.
|
|
|
|
|
Hello everyone,
After attempting to create a Telegram project capable of downloading videos either directly sent to the bot or through a Telegram link in the format (https://t.me/channelname/postid), I initially utilized the Telegram Bot API. I managed to fetch updates sent to the bot I created, retrieve the video's file ID and caption, and download the video with the caption as its name. However, I encountered a size limit issue (20 MB).
Subsequently, I learned that another API, the MTProto Telegram API, does not impose a size limit. I created the application and obtained the API ID and API hash. Although I downloaded the "telenet" project, I couldn't find a function specifically for downloading files. Could anybody provide assistance?
I aim to download either video files sent to the bot or videos contained in Telegram links. I'm willing to share my two projects: the Telegram Bot API and the MTProto API.
Thank you in advance.
Regards
|
|
|
|
|
When it comes to APIs you are much better off starting by talking to the people who created it - the chances that anyone on a random website has used your specific API and notices your question are vanishingly small - the API vendor should provide tech support or at least documentation and if they don't then why the heck are you using it?
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
Hello community! 👋
I'm excited to share a free open-source tool I've been working on called AD Sync Manager. If you manage Active Directory and Azure AD synchronization in your environment, this might be useful for you!
https:
AD Sync Manager is designed to help streamline and simplify the AD to Azure AD sync process. It provides an easy way to monitor sync status, get alerted on issues, and manage sync cycles.
With this tool, you can:
View the status of your AD Connect sync cycles
Get notified if delta or initial sync fails
Manually trigger full or delta syncs
Analyze sync errors to identify objects with issues
And more!
It's built with PowerShell so it should be easy to deploy in most AD/Azure environments. I'm actively developing it and welcome any feedback or suggestions.
If you struggle with keeping your on-prem and cloud directories in sync, give AD Sync Manager a try. Let me know if you have any questions - I'm happy to help!
Hopefully this tool saves you some time and headaches. Let me know what you think! 😊
|
|
|
|
|
This is the wrong place to post this as thsi forum is for C# discussions - try the Free Tools Discussion Boards[^] instead.
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
Hello all,
I am working on on functionality in which i want to write a c# function which will read XML file from folder.
And it will write .txt file from it and will put it in other folder.
can some one help me to do this, when i am reading XML file line by line i should able to write any error or log in log file, if some thing is wrong it should rollback all file else generate .txt file.
Needs to implement it using any design pattern.
|
|
|
|
|
Technically, an XML file is already a text file. All you need to do is change the file extension.
Now, if you actually want to transform the XML in some way, then you're going to need to either write code to do it, or write an XSLT transform[^] to do it.
But since you've provided precisely zero details about the input and expected output, nobody can possibly help you.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
There are several tools for reading an arbitrary XML file into a DOM tree. Use that, rather than reading XML line by line.
This is a plain tree that can easily be traversed like any other tree, usually with a recursive procedure. Depending on the data in the tree and your requirements for the result, you do the traversal depth first or breath first. When you find some value that appears to be text of the kind you are after, you write that to your text output file and continue the search.
Maybe there XML structure contains non-text information that you should nevertheless interpret, and produce the appropriate output. E.g. if a node is flagged as a h1, you will probably want to add an extra blank line above the heading text.
Religious freedom is the freedom to say that two plus two make five.
|
|
|
|
|
Member 12116052 wrote: XML ... put it in other folder.
1. Read and process the XML
2. Determine the output.
3. Open the output file
4. Write 2 to the file from 3.
Member 12116052 wrote: when i am reading XML file line by line i s
Nope. Bad idea.
You do not read XML 'line by line'. Rather you parse it. And then extract values from what you parsed.
If and ONLY if the source of the XML can be guaranteed to be an automated single source, then you can roll the dice and attempt to write your own parser (not an XML parser) which can parse individual lines. Thus skipping the XML learning curve.
And also making your code sure to break if the format of the XML changes.
|
|
|
|
|