小编luc*_*dru的帖子

并行读取和处理文件C#

我有非常大的文件,我必须阅读和处理.这可以使用线程并行完成吗?

这是我做过的一些代码.但它似乎没有得到更短的执行时间读取和处理文件一个接一个.

String[] files = openFileDialog1.FileNames;

Parallel.ForEach(files, f =>
{
    readTraceFile(f);
});        

private void readTraceFile(String file)
{
    StreamReader reader = new StreamReader(file);
    String line;

    while ((line = reader.ReadLine()) != null)
    {
        String pattern = "\\s{4,}";

        foreach (String trace in Regex.Split(line, pattern))
        {
            if (trace != String.Empty)
            {
                String[] details = Regex.Split(trace, "\\s+");

                Instruction instruction = new Instruction(details[0],
                    int.Parse(details[1]),
                    int.Parse(details[2]));
                Console.WriteLine("computing...");
                instructions.Add(instruction);
            }
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

c# multithreading

16
推荐指数
2
解决办法
3万
查看次数

Mysql无法创建表errno 121

为什么我收到此错误?我没有任何外键

drop table if exists t_issue;
SET foreign_key_checks = 0;SET storage_engine=INNODB;
CREATE TABLE `t_issue` (
`id_issue` int(11) NOT NULL PRIMARY KEY AUTO_INCREMENT,
`fk_project` int(11) DEFAULT NULL,
`subject` varchar(255) DEFAULT NULL,
`estimated_due_date` date DEFAULT NULL,
`due_date` date DEFAULT NULL,
`done_ratio` int(11) DEFAULT NULL,
`fk_status` int(11) DEFAULT NULL,
`fk_assigned_to` int(11) DEFAULT NULL,
`fk_owner` int(11) DEFAULT NULL
) ENGINE=innodb DEFAULT CHARSET=latin1
Run Code Online (Sandbox Code Playgroud)

mysql

13
推荐指数
1
解决办法
2万
查看次数

尝试重置git HEAD时出错

我试图通过使用删除本地存储库中的最后一个提交

git reset --hard HEAD~1
Run Code Online (Sandbox Code Playgroud)

命令.但是我收到以下错误:

fatal: Could not reset index file to revision 'HEAD~1'.
Run Code Online (Sandbox Code Playgroud)

我明白了

(Filename too long)
Run Code Online (Sandbox Code Playgroud)

对于几个文件.我怎么能避免这个?我在Windows上

git

7
推荐指数
1
解决办法
6137
查看次数

区分c#中的TcpClient

作为服务器,我如何区分连接到我的TcpClient?作为客户,我是否总是必须发送用户名或服务器可以知道我是谁的用户名?

c#

5
推荐指数
1
解决办法
571
查看次数

Maven Surefire Junit 测试套件

我使用 Maven Surefire 插件来运行一组特定的测试。例如:

package suite;

import org.junit.runner.RunWith;
import org.junit.runners.Suite;

import suite.slow.EvenSlowerClassTest;
import suite.slow.SlowClassTest;

@RunWith(Suite.class)
@Suite.SuiteClasses({
    SlowClassTest.class,
    EvenSlowerClassTest.class
})
public class SlowSuite {

}
Run Code Online (Sandbox Code Playgroud)

通过使用maven命令

test -DrunSuite=**/FastSuite.class -DfailIfNoTests=false
Run Code Online (Sandbox Code Playgroud)

我可以显式运行 FastSuite 或 SlowSuite 测试套件,但是,如何运行我拥有的所有测试套件或测试套件中未涵盖的所有测试?

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-surefire-plugin</artifactId>
    <configuration>
        <includes>
            <include>${runSuite}</include>
        </includes>
    </configuration>
</plugin>
Run Code Online (Sandbox Code Playgroud)

java junit surefire maven

5
推荐指数
1
解决办法
7049
查看次数

ExtJs XTemplate if语句包含特定的css

有人能举例说明如何在Extjs中使用XTemplate来包含特定的css类吗?

<tpl if="total > 5000">
     yellow css
<tpl else>
   red css
</tpl>
Run Code Online (Sandbox Code Playgroud)

编辑: 我有这样的事情

new Ext.XTemplate('<span style="display:inline-block; margin-right: 730px;"">' + title + ' ({count}) </span>',
    '<span ',
        '<tpl if="priceTotal &gt; 5000"> style="color:black;" class="x-form-item-label x-form-warning"</tpl>',
    '> {priceTotalLabel}:  {priceTotal}',
    '</span>'
);
Run Code Online (Sandbox Code Playgroud)

我想用变量中的值替换值5000,所以它不是硬编码的,我该怎么做?

css extjs

4
推荐指数
1
解决办法
4391
查看次数

C#中的线程导致无限循环并阻塞我的应用程序

我创建了一个Thread,我只需要从表单的左侧移动一个radiobutton.这运行,但我的应用程序被阻止,我无法移动表单,没有(我认为这是创建线程的原因,同时做多个事情)这是我的代码,我希望你明白我问.提前致谢

    private void moveRight( )
    {
        radioButton1.Left++;
    }
    private void moveLeft()
    {
        radioButton1.Left--;
    }
    public void run()
    {
        while (true)
        {
            while (radioButton1.Left != this.ClientSize.Width - 10)
            {
                if (InvokeRequired)
                {
                    Invoke(new MethodInvoker(moveRight));
                }
                else
                {
                    moveRight();
                }
            }
            while (radioButton1.Left != 10)
            {
                if (InvokeRequired)
                {
                    Invoke(new MethodInvoker(moveLeft));
                }
                else
                {
                    moveLeft();
                }
            }
        }
    }

    private void button1_Click(object sender, EventArgs e)
    {
        t = new Thread(new ThreadStart(run)); 
        t.Start();
    }
Run Code Online (Sandbox Code Playgroud)

c#

2
推荐指数
1
解决办法
1170
查看次数

maven pom xml变量

设置依赖项时.我们假设如下

<dependency>
        <groupId>com.atlassian.plugins</groupId>
        <artifactId>atlassian-plugins-osgi-testrunner</artifactId>
        <version>${plugin.testrunner.version}</version>
        <scope>test</scope>
</dependency>
Run Code Online (Sandbox Code Playgroud)

在哪里

${plugin.testrunner.version}
Run Code Online (Sandbox Code Playgroud)

变量初始化?是否有属性文件或它获取值的位置?

java maven

2
推荐指数
1
解决办法
1998
查看次数

Gitblit推动被拒绝的原因没有在intelij-idea中显示

如果我在Eclipse或其他git客户端上添加拒绝推送的挂钩,则会显示拒绝消息.
但是,如果我使用intelij-idea,则不会显示拒绝原因.

这可以配置为在JIdea中显示吗?

git intellij-idea gitblit

2
推荐指数
1
解决办法
9462
查看次数

线程导致IndexOutOfBounds异常

这段代码导致IndexOutOfBoundsException任何人都可以告诉我为什么?我无法理解它导致IndexOutOfBoundsException的原因

private static String TRACE_PATH = "..\\..\\TRACES";

static void Main(string[] args)
{
    if (Directory.Exists(TRACE_PATH))
    {
        String[] traceEntries = Directory.GetFiles(TRACE_PATH);
        Thread[] traceReaders = new Thread[traceEntries.Length];


        for (int i = 0; i < traceEntries.Length; i++)
        {
            traceReaders[i] = new Thread(()=>readTrace(traceEntries[i]));
            traceReaders[i].Start();
        }

    }

    Console.Read();
}

private static void readTrace(String traceFile)
{
    using (StreamReader sr = new StreamReader(traceFile))
    {
       //code to use the trace file...
    }
}
Run Code Online (Sandbox Code Playgroud)

c# multithreading

1
推荐指数
1
解决办法
86
查看次数

标签 统计

c# ×4

git ×2

java ×2

maven ×2

multithreading ×2

css ×1

extjs ×1

gitblit ×1

intellij-idea ×1

junit ×1

mysql ×1

surefire ×1